# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

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

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.

Any help would be greatly appreciated!

-Michael

Message 1 of 9
(3,134 Views)

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

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

Message 2 of 9
(3,125 Views)

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

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

Message 3 of 9
(3,118 Views)

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

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

Message 4 of 9
(3,113 Views)

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

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!

Message 5 of 9
(3,069 Views)

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

here is a sample vi

Message 6 of 9
(3,062 Views)
Solution

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

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

Message 7 of 9
(3,030 Views)

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

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

Message 8 of 9
(3,002 Views)

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

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

Thank you!

Message 9 of 9
(2,991 Views)