LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot plane using 3D surface plot with equation for the plane

I have a set of data, that I have calculated the best-fit plane for. I have the equation of the plane in the form of Ax + By +Cz = D. However, I am having difficulty getting the plot correct. I have attached pictures showing the relevant portion of my block diagram. In the inner most for loop, I have the equation solved for z, as in z = (D - Ax - By) / C.

 

I have each for loop running from -50 to 50 with a step size of 1. These define my x and y vectors. My z matrix is defined by the plane equation, solved for z in the inner most loop.

 

This works for some data sets, but not all. For example, it works for when the plane equation is:

 

0.0229x + 0.7305y + 0.6825z = 48.9015

 

But not when the equation is:

 

0.5373x + 0.4914y + 0.6855z = 49.5302

 

I have tested my calculations in MATLAB, and the plane plots correctly, so I know that the equation itself is correct. But I do not have to create a z matrix based on x and y vectors in order to plot a plane in MATLAB. I can plot straight from the equation and boundary parameters. So what am I doing wrong in my setup for the plot in LabVIEW?

 

Relevant portion of my block diagram:

Block Diagram.PNG

Plot from first equation example, where it plots correctly.

Correct2 0-45.PNG

 

Plot from second example, where it plots incorrectly:

Incorrect plot 45-45.PNG

 

0 Kudos
Message 1 of 6
(4,295 Views)

Hi w5alyh,

 

This forum post might be helpful. Is it possible to post the block diagram image as a VI snippet? VI snippets are PNG files, but it can be dropped in a block diagram and turn into LabVIEW code.

 

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 6
(4,266 Views)

Here's the VI snippet that you asked for. Also, I have looked at that forum post before. My problem is that I do not understand how to interpolate my data to get the result that I want. Can you explain the math behind that?

0 Kudos
Message 3 of 6
(4,252 Views)

Hello,

 

For 3D surface plot, it needs a 2D array that defines the z value for every point in x and y. Thats why the interpolation is there. The 3D Surface Graph VI in the NI Example Finder is good one. You can find by clicking on "Help" -> "Find Examples" -> selec the "Search" tab -> search "3D Surface Graph".

 

Try a very simple plane equation like x+y+z = 0. It didn't come up right on my side. Double check your LabVIEW logic as well.

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 6
(4,215 Views)
I guess the part that I don't understand is how to interpolate the data. Can you give an example of the math behind that? I based my block diagram off of the example vi that you mentioned, but it only works some of the time. The issue seems to be in the x- or y-plane or both.
0 Kudos
Message 5 of 6
(4,209 Views)

Hi,

 

Give the "Scattered 2D Interpolation.vi" example a try. The context help of each VI explains what they are doing. The LabVIEW Help page of the Interpolate 2D Scatterred VI also provide a link on math related documented. 

 

In terms of the math behind interpolation, I think the Wikipedia page on interpolation is pretty decent. 

Ren H.
Applications Engineering
National Instruments
0 Kudos
Message 6 of 6
(4,191 Views)