05-31-2016 02:24 PM
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:
Plot from first equation example, where it plots correctly.
Plot from second example, where it plots incorrectly:
06-01-2016 10:17 AM
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.
06-01-2016 12:00 PM - edited 06-01-2016 12:02 PM
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?
06-02-2016 01:55 PM
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.
06-02-2016 01:59 PM
06-03-2016 10:25 AM
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.