05-11-2015 11:36 AM
Hi, I´m working with LabviewRobotics, generating a matrix (occupancy grid), the values in the matrix are 0 or 100.
I want to plot this information into a XY graph, where 100 will be a point in the graph.
What I need is to get all the combinations (x,y) where the matrix element has the value of 100, anyone know how to do this in a simple way?
Solved! Go to Solution.
05-11-2015 11:48 AM
Autoindex the 2d array on a stack of two FOR loops and build an array based on the two iteration terminals in the innermost loop, auto indexing using a conditional a output tunnel. Use a concatenating tunnel on the outer loop.
05-11-2015 12:00 PM - edited 05-11-2015 12:01 PM
For some reason I cannot post the VI (it says file extension does not match the file type). Here is a picture of my block diagram for now. False case just wires the arrays straight through.
05-11-2015 12:10 PM - edited 05-11-2015 12:28 PM
@Gregory wrote:
Here is a picture of my block diagram for now. False case just wires the arrays straight through.
Why is the scalar control on the innermost loop? That belongs outside because it should not change during the execution of the loops!
With modern LabVIEW versions, here's how my suggestion would look like. Arguably much simpler. (note that xy graph accept complex arrays directly)
(Of course you can swap the indices depending on how you want the output arranged.)
Alternatively, you could reshape to a 1D array, use "search 1D array", and transform the 1D indices back to 2D using quotient&remainder.
05-11-2015 12:28 PM
I learned a couple neat tricks there!
05-13-2015 10:37 AM
It worked really fine, I was trying something similar, but i couldnt actualize de values, the shift registers was the part I was missing, thank you
05-13-2015 10:39 AM
Hey, thank you, I dindn´t know i could send complex to an XY graph, I´m reducing my code now in different parts thank to this... nice tip
05-13-2015 10:44 AM - edited 05-13-2015 02:10 PM
@genzo436 wrote:
the shift registers was the part I was missing, thank you
I wasn't using a shift register either. Do you have an older LabVIEW version?
Here are some alternative versions that don't use fancy tunnels. Same difference. 😄