LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

obtaining specific values from an array

Solved!
Go to solution

 Line 10 from the block diagram creates an array after taking the values from the array x and y from line 1 and then does the following calculation xsin(theta)+ysin(theta). ---> represented in table in front panel

What i need to know is how to create an array made of the x and y that give the value of xpos, in this case, 1 in the Table from the front pannel.

 

left side.jpg

 

0 Kudos
Message 1 of 22
(4,146 Views)

You have 35 lines of mathscript code.  You have 11 arrays of controls or indicators on your front panel.  I have no idea what you are describing what you want to do.

 

All I can do is suggest you go through the array palette with context help open so you can see what the array functions do and figure out how to combine them to do what you want.

 

I've got a feeling that by using the mathscript node, you are making this way more complicated than it needs to be.

0 Kudos
Message 2 of 22
(4,137 Views)
You will probably do better submitting such a question to a MatLab forum.  Most people here only like to read wires.
0 Kudos
Message 3 of 22
(4,124 Views)
Battler, I think I will also look for help in the matlab forum
0 Kudos
Message 4 of 22
(4,106 Views)
What I am doing is the following: I have 2 arrays, one is for my x value and the other is for my y value. I use the values of those arrays to calculate r=x*cos(t)+y*sin(t). Those t are for the theta angles t=0:pi/2:pi. After I calculate r, I have another array, that stores all those r values.
I want to get the values for x and y that gave me an specific value for r. For instance:
x(an array)      y (an array)         r (an array)
5                   7                      0     1      2
1                   3                      1     3      2    (every column represents angles t)
4                   2                      1     2      4    (every element is the product of using r)

Column 1 has two 1's which was the result of using x=1 and y=3 and x=4with y=2 for angle 0. What I want to do is to get those x's and y's values to put it in an array.
My matlab code is:
x=row; y=col
t=0:pi/2:pi
r=[]
r=[r abs(x*cos(t)+y*sin(t)]
if r=1
need to create an array that tells me what values of x and y gave r =1 and store them in a new array
Can someone help me with this? Is it clear now?

0 Kudos
Message 5 of 22
(4,101 Views)
Use Index Array to get the 0th column of your 2-D array.  That yields a 1-D array.  Use Search 1-D array to search for the 1's.  The indices returned from that will be the rows of the 2-D array, and thus the elements of your 2 1-D arrays.
0 Kudos
Message 6 of 22
(4,093 Views)

How can I put those index values in an array. I tried to use build array but it didn't work. Any idea?

 

index.jpg

0 Kudos
Message 7 of 22
(4,077 Views)
Why are you indexing out the ith column determined by ypos, and searching for the element that matches the value of xpos?  That doesn't match at all with what you said you want to do.
0 Kudos
Message 8 of 22
(4,069 Views)
xpos is my r and ypos is the column I want to extract.
0 Kudos
Message 9 of 22
(4,064 Views)

Use index array to get the 0th column of your 2-D array called table (not ypos as you have now).  Search 1-D array on that for 1, not Xpos as you have now.

 

Now that you have an element, you know which element of X array and Y array to extract.  If needed, do the search for 1 in a loop to find the other instances.

0 Kudos
Message 10 of 22
(4,061 Views)