LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I plot three 1-D vectors into a surface plot?

Solved!
Go to solution

Hi everyone,

 

I have programming experience but am completely new with LabView.

I have data files that contain the same wavelength range on the first column, light intensities on the second column, and each new text file is at a different angle. The respective angles are written as headers for each file.

I've extracted wavelength, intensity, and angle into distinct 1-D vectors and want to plot them all on a 3-D graph.

 

I've tried using scattered plots in vector form, contour plots, plot3Dmesh, etc, and I've googled extensively and have found similar questions but no answers.

 

Does any one know where I can view specific examples or how to go about this?

 

Any help would be greatly appreciated!

 

-Michael

0 Kudos
Message 1 of 9
(2,952 Views)

One of those 1D vectors will need to be a 2D array. I would think you would want to plot frequency vs angle and have the 2D array be the intensities. Here's a VI that creates all the data then plots it. Hope this helps

0 Kudos
Message 2 of 9
(2,943 Views)

Thanks for example, it's clarified some 3D graph issues! I'm still working on this plot though..it's not quite happening yet.

 

I have a similar setup except for the intensities loop through each file and build arrays that append to each other side by side. I see the plot momentarily displaying freq vs intensity as it loops through the files in my directory but then it disappears. Each time a file passes it creates a 1D array of the intensities at that angle. I use the Build Array programming function that concatenates multiple arrays and outputs it as a 2D array of appended elements.

 

In your example code, I'm not sure I understand how a 25x25 ends up being a 2D array. Are the arrays side by side or are they appended at the end of each other?

 

Thank you!

 

-Michael

0 Kudos
Message 3 of 9
(2,936 Views)

Hi Michael

To make the 2D array I'm indexing the output from each For Loop. Each time the inside loop runs it adds a scalar value to the output then when the loop is done running it passes all of the values as a 1D array. The outside For Loop is indexing 1D arrays so when it's all done the output is a 2D array. I hope I said that correctly. If you have 1D arrays already and just need to compile them into a 2D array you can either use the "array size" vi to tell the For Loop how many times to run or if there is just one indexed input it will run that many times. If you right click the little square where it goes into the for loop you can choose wether to index the values or pass them as an array.

Good luck

0 Kudos
Message 4 of 9
(2,931 Views)

Hello mojojojo,

 

I've been trying to get this graph to work and so far the data displays an intensity curve for each file, but only individually as the file is read through the recursive file list and plotted. (I'm reading a bunch of files from a directory and extracting the necessary data columns.) It doesn't make a surface, only a brief line in 3D space and then disappears as the next file is read.

My angles and wavelengths are 1-D arrays of DBL elements on the x and y axes and my intensity is a 2-D array of DBL elements on the z axis. It should display correctly I think...

Is there any way to have a 3D plot not clear the data as it's plotted? Kind of in the same way that the Build an XY Graph VI has the option to clear or not clear the data on each call?

 

Thanks!

 

All the info you've given me has been helpful regardless!

0 Kudos
Message 5 of 9
(2,887 Views)

here is a sample vi

0 Kudos
Message 6 of 9
(2,880 Views)
Solution
Accepted by topic author MichaelHadrien

Hi Michael

I think I see the problem if I understand you correctly. You have the plot inside the For loop. That will re-write the plot on each run. I've made some changes to your VI. I'll just write comments on the block diagram. See if this makes sense.

Joe

 

0 Kudos
Message 7 of 9
(2,848 Views)

Hi Joe,

 

Thank you! That worked. It enlightened me a bit more about shift registers as well.

The reason I'm taking both the angles and wavelengths from the same column is because the angles are the first value on the numerical header. The wavelengths (and intensities) all begin from row 3 so I just set the read from measurement file VI to start there.

 

There's one odd thing about the plot. Everything looks fine up until it hits ~340 on the wavelengths. All the angles are read and intensities for wavelengths between 260-340 nm. But the wavelengths range from 260-680 nm. I've been playing around with the shift registers insert into array functions, but I can't figure out what's stopping it from plotting the remaining intensity curves after 340 nm. I suspect it has to do with the number of times the for loop runs, but I thought the list folder files function took care of that. I tried wiring the file count output to N on the for loop but it didn't make a difference. Any thoughts on this?

 

Note: there are 176 angles, from 0-175. there are around 400 wavelengths, from around 260-680 nm.

 

Thank you so much!

 

-Michael

0 Kudos
Message 8 of 9
(2,820 Views)

nevermind I figured it out...somehow switches the x and y axes worked.

Thank you!

0 Kudos
Message 9 of 9
(2,809 Views)