LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

arranging x, y pairs in Intensity chart

I have 3 Arrays
----------------
x y z
----------------
0 0 1.62
5 1 2.25
10 2 1.4
15 3 0.95
. . .
. . .
. . .
. . .

Each x, y pair represents z intensity value like (0,0)-> 1.62 and (5,1)-> 2.25. The x array is in multiples of 5 up to 10540 and y array is up to 2047 so both arrays are of size 2048
I need to make 2D array of these x, y pairs which stores the respective z-intensity value to plot on Intensity chart.

 

I have found this but unable to understand 

Help with XY intensity graph - NI Community

 

EDIT: sometimes the y values goes to negative side like (5,-0.9)->1.47 then how to array 2d array and how to plot negative side on y axis.

0 Kudos
Message 1 of 17
(3,159 Views)

What part didn't you understand? Seems simple enough!

 

  • Initialize a 2D array of size 2048x2048.
  • Create a FOR loop and place the 2D array inside a shift register.
  • Autoindex you xyz arrays on the FOR loop.
  • for each iteration, use x (divided by 5) and y as index and z as value and use replace array subset to place it.
  • repeat for all values.
  • (Actually, if X and Y are nicely sorted and there are no gaps, it might be sufficient to reshape the z array to a square 2D array, so try this instead!!)
  • Set dx of the x axis at 5 to get the markers right. Pick a reasonable color scale for Z.

 

If you want specific help, attach a simplified VI containing a typical dataset of xyz.

0 Kudos
Message 2 of 17
(3,157 Views)

i have attached my vi with data

0 Kudos
Message 3 of 17
(3,135 Views)

@sheshu9a1 wrote:

EDIT: sometimes the y values goes to negative side like (5,-0.9)->1.47 then how to array 2d array and how to plot negative side on y axis.


You'd linearly scale the values. If the graph is 0-1999 pixels, linearly scale so the minimum value becomes 0, the max becomes 1999.

 

Something in the lines of:

Ygraph = (Y - Ymin) / (Ymax - Ymin) * (width-1)

0 Kudos
Message 4 of 17
(3,100 Views)

@sheshu9a1 wrote:

i have attached my vi with data


 

Well, that has nothing to do with the original question, because you now use rcos and rsin as x and y and these are NOT integers!

Maybe you want to explain why you generate 9 different datasets and overwrite them in the intensity graph as fast as the computer allows, leaving you with only the last set? Seems pointless.

 

In the original problem, x and y are linear ramps of integers! (0,1,2,3, ... or 0,5,10,15, ... resp.). What happened to that?

 

Why exactly are you using an intensity chart instead of an intensity graph??? Do you know the big different?

0 Kudos
Message 5 of 17
(3,092 Views)

I have cleaned up your code a bit (No chage in functionality, but replaced chart with graph) and here's how it could look like:

 

altenbach_0-1637340521305.png

 

0 Kudos
Message 6 of 17
(3,088 Views)

Hi, thanks for your reply

I have a data acquisition card which gives intensity values (1d array of 2048 size). I am trying to represent angle values of gimbal (azimuth and elevation) the X-axis is azimuth and Y-axis is elevation. The bin(index) number of intensity value array gives the range the formula goes like this X-axis = rCos(angle) Y-axis= rSin(angle). Both the X and Y axis go negative range in certain angles. So far I have tried this, the XY graph in the vi is the data i want to have in intensity graph (i.e; represent the intensity values in that particular angle).

0 Kudos
Message 7 of 17
(3,048 Views)

So does it work they way you want?

 

(Still seems overly complicated. You have only 2048 points so there is a lot of redundancy (e.g. the point at 0,0 gets overwritten by the same value 2048 times!) AND you have gaps between the rays (i.e. pixels that never get hit).

 

Maybe you want to iterate over each pixel, get the distance from the origin, and color it accordingly...)

0 Kudos
Message 8 of 17
(3,027 Views)

@altenbach wrote:

Maybe you want to iterate over each pixel, get the distance from the origin, and color it accordingly...


Here is a quick example for that. Note that the use of "interpolate array" will do a linear interpolation for fractional indices. 

 

altenbach_0-1637480704823.png

 

 

0 Kudos
Message 9 of 17
(3,021 Views)

... and if you subtract 1024+1024i right before taking the absolute value, you can even center the data. 😄

 

altenbach_0-1637481007605.png

 

0 Kudos
Message 10 of 17
(3,015 Views)