LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining equations with 3D graph



@Honeywell wrote:
Still having a hard time coming up with a VI that gives me 2D polynomial equation. 😞


That seems to be easy. One possibility is attached (LabVIEW 6.1) 🙂

Inputs: x, y, coefficients[]
Output: Z
Message 31 of 40
(2,293 Views)
Hi,

Just took a look at that last VI but I don't think that's what I want.

What I need the program to do...

Input 3 matrices (X, Y, Z) and find the 2D polynomial equation (z= a + bx + cy + dx^2 + ey^2 + ....)

Right now that program takes X and Y and just inputs them into the polynomial equation.

Sorry if I didn't make it clear earlier.
0 Kudos
Message 32 of 40
(2,267 Views)
Found the following VI on National Instruments' website. Unfortunately it's LV 7.1. Could someone convert it to 6.1 so I can see if that's what I want to do? Thanx.

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B123AE0CBB3C111EE034080020E74861&p_node=DZ53022&p_source=external
0 Kudos
Message 33 of 40
(2,263 Views)
Here you go.

Be aware that it incorporates all xy mixed terms but it should be easy to adapt.

(It goes along the alternative idea mentioned (General LS fit) in my last paragraph here. I was just starting to make my own example, but this should get you started).
Message 34 of 40
(2,253 Views)
Thanx!

Just took a look at the VI and that looks like what I have in mind. Except now I need it in 2D matrice not 1D. I'll play around with it.
0 Kudos
Message 35 of 40
(2,251 Views)
Thanx!

Just took a look at the VI. It looks similar to what I want to do except I need the arrays in 2D.

The program seems to calculate the cross terms as well. Don't need that.

I'll try and see what I can do with this (probably not too far though 😞 )
0 Kudos
Message 36 of 40
(2,245 Views)
The array dimensions don't really matter for the problem.

You can reshape the 2D arrays to a 1D array for fitting, then reshape he Z' result back to the original dimension at the end. Reshaping an aray is computationally very cheap, because it just reinterprets the array without touching it in memory (see the online help on "reshape array").



After all, you simply need to operate on a collection of (x,y,z) points, it does not matter how they are arranged. The result will be the same if I uderstand your problem correctly.

Message Edited by altenbach on 06-14-2005 12:12 PM

Message 37 of 40
(2,244 Views)
Hi I missed your post about reshape 2D array into 1D array.

If I do that on Using3DPolyFitandEvaluation would that give me the correct polynomial constants? I'm having a bit of difficulty following the math here. :S
0 Kudos
Message 38 of 40
(2,229 Views)
OK, here's a simple demo of what I originally had in mind (LabVIEW 6.1).

Inputs are 2D arrays for X and Y, an arbitrary odd number of coefficients (determining the poly order!) and gaussian noise.
This simulates noisy Z data (Here you would substitute your own Z data!) which is then reshaped and input into the General LS fit.

The H matrix is calculated from the X and Y arrays based on the number of coefficients.

Just run it with the default inputs for a demo.

I added some annotations, see if it makes sense to you. Good luck! 🙂

Message Edited by altenbach on 06-14-2005 02:12 PM

Message 39 of 40
(2,230 Views)
I cannot believe that nobody objected to my rather inefficient way to generate the H matrix. (Lots of empty operations and additions of zeroes. It was just a quick and safe way to re-use the original formula ;)).

I thought I'd quickly rewrite that part for cleaner and more efficent code, works the same but is probably faster. 🙂

See if it makes sense. Enjoy!
Message 40 of 40
(2,197 Views)