LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add element to matrix/2d array

Solved!
Go to solution

Hello forum users- 

 

 

I'm working on an application that uses a mobile robot to map out an area.

 

To do this, I get 16 sonar readings once every second. These sonar readings give me an X and Y  coordinate of where an obstacle is.

 

Now what I want to do is make a matrix/2d array that I define the inicial size as 501 by 501 and have all the elements of this matrix be zero. For each of my sonar readings I want to add 1 to a specific cell of the matrix. 

 

(example lets say that that robot detects the first object at position 400x400 this cell instead of being zero would have a value of 1).

 

The final product should be a 3d mesh/surface graph that updates as the robot moves around the room (updated at 1 second intervals).

 

I know it could be done in Matlab so I figured I could use the MathScript Node but can I export the mesh function to my front panel???

 

 Thanks for the help

 

Bruno Noronha

Certified LabVIEW Associate Developer





Using LabVIEW 8.6
0 Kudos
Message 1 of 6
(6,630 Views)

Hi bnoronha,

  If you use mesh function in a mathscript node,,you will get a pop up with a  3d-mesh/surface graph and that will be slow also.istead you can use inbuilt indicators for surface plot ...you can search examples also..

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 6
(6,613 Views)

bnoronha wrote: 

Now what I want to do is make a matrix/2d array that I define the inicial size as 501 by 501 and have all the elements of this matrix be zero. For each of my sonar readings I want to add 1 to a specific cell of the matrix. 


 

 
 Initialize a 2D array of the desires size (e.g. 501x501). You would use a while loop with a shift register initialized by the 2D array of zeroes.
 
Inside the loop you would increment the desired location using the "in place element structure". You can display the 2D array using a 3D surface graph or even a simple intensity graph.
 
See how far you get.... 
0 Kudos
Message 3 of 6
(6,604 Views)
Solution
Accepted by topic author bnoronha

Here's some quick code showing a 2D histogram, displayed in 2D or 3D.

 

Modify as needed. Of course if you want to cap the z-axis at 1, simply use "replace array subset" with "1" as element instead of the current "in place" structure.

Message Edited by altenbach on 06-09-2010 10:29 PM
Download All
Message 4 of 6
(6,596 Views)

altenbach that was exactly what I was looking for.

 

Thanks a million!!!!  :smileyvery-happy:

 

Kudos to you!

Bruno Noronha

Certified LabVIEW Associate Developer





Using LabVIEW 8.6
0 Kudos
Message 5 of 6
(6,586 Views)
It is the "in place element" structure with index array mode. Can't you download the VI?
0 Kudos
Message 6 of 6
(5,441 Views)