LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

obtaining specific values from an array

Solved!
Go to solution

The reason I am indexing out that column is because I have to work only with the column designated by ypos. Once I have that column, I have to create an array that tells me what values of x and y gave r =1 and store them in a new array.

 

0 Kudos
Message 11 of 22
(1,937 Views)

That doesn't match what you said in message 5 where you talked about searching column 1 (actually the 0th column) for the 1's.

 

Quote:

"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."
0 Kudos
Message 12 of 22
(1,935 Views)

That was a for instance. 

 

"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." Now, what I want to do is to "get the values for x and y that gave me an specific value for r."

 

0 Kudos
Message 13 of 22
(1,931 Views)

NEVCH,

Your problem is an easy one using MATLAB and LabVIEW, but your description of the problem is not clear or confusing.

 

1.       You have used MATAB functions inefficiently, try and use MATLAB built in functions, then use (for and if) sparingly.

2.       Your example of x, y, r, and t is not correct.  x = [5 1 4], y = [7 3 2] and t = [0  pi/2  pi], if you do that r = abs(x*cos(t) + y *sin(t)), you will not get what you have .

 

In any case, I have included an example of what you might need, perhaps if you can be more specific with your example, I can help further.

 

MATLAB is extremely powerful, when it comes to array manipulation, so in your final answer everything can be done within the MATLAB script; all you need to do is output your final answer to LabVIEW from MATLAB.

 

 

specific values.jpg

 

If you can give example as follow, then it will be helpful for everyone trying to help you out.

10 values of array x

10 values of array y

Your expected (correct) values of array r

The final output you want on your front panel from the given x, y, and r.

 

0 Kudos
Message 14 of 22
(1,915 Views)

ade77, 

 I trying to do the following:

using the values from the row and col, I am getting r which is obtained from r=xcos(t)+ysin(t). Every column represents the values of r using angles  t=0: pi/6:pi, meaning colum one has the values of r for angle 0, the second column has the values of r for pi/6 and so on until it reaches pi. By the way, in the equation of r, x=row and y=col.

Next, for every column (meaning for every angle) in the array r, I look for the number that repeats the most. For that reason I created another array N, to find out what that value is. As we can see from the array N, r=1 from angle 2pi/3 is repeated 3 times. So what I do next is find out for what values of row and col, I get r=1, and extract them into a new and final array.

This final array is labeled as new_array which is almost right except that is not showing row=1 col=2

Hope it is clear? If not let me know, and I will try another way to explain it. 

 

front panel.JPG  block diagram.JPG

0 Kudos
Message 15 of 22
(1,906 Views)

I still don't know what you are looking for.  Everytime you explain it, you add a new requirement.

 

Now you've added

 

"Next, for every column (meaning for every angle) in the array r, I look for the number that repeats the most. "

0 Kudos
Message 16 of 22
(1,896 Views)

NEVCH,

 

I clearly understand what you want. Unfortunately, I do not have access to LabVIEW right now. if you can wait till evening about 9 pm EST, then I will post it to you.

 

Your problem is just simple array manipulation using MATLAB or mathscript. by the way, do you have access to MATLAB, because I prefer to use MATLAB , rather than mathscript.

 

In the meantime, you might want to read this help functions in MATLAB:

 

logical indexing

sort

unique

find

 

Hope this helps.

 

Ade

0 Kudos
Message 17 of 22
(1,885 Views)

dear ravens fan, ade77 asked me to post exactly what I was doing so he could understand exactly I was trying to do. It seems I was not being clear enough or confusing people. For this reason, I decided to organize and post what I was really doing. But your ideas help me explore other alternatives, it help a great deal too. 

As far as finding the number that repeats the most, I already did that. I was afraid that if i explained the whole idea of what i was doing i will get everybody confused, so i opted to choose a simple example to explain what i was doing,  and use that idea to implement it in my original idea.

Sorry for confusing you. 😞 

0 Kudos
Message 18 of 22
(1,880 Views)
While I wait for you, i will look into those function. and yes I have MATLAB. why sort, though? isn't that to arrange values in an ascending or descending order only? if I do that would that mess with the indexes? I guess I better read, and shut up for now. Thanks in advance for your help.
0 Kudos
Message 19 of 22
(1,877 Views)
Solution
Accepted by topic author NEVCH

NEVCH,

 

I have attached a working code for you. The MATLAB functions I used might be unfamiliar to you, but you can look at the documentation in MATLAB to expand  your knowledge. Be aware that this functions are not available in Mathscript.

 

You can add a while loop if you like, then you will be able to interactively change the values of row, col , and value. I have generalized the problem to work with as many columns or rows, or you can change the value of 'value'.

 

specific array.jpg

Feel free to ask any question or comment

 

Ade.

Message 20 of 22
(1,842 Views)