LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D Non-Linear Curve Fitting

Solved!
Go to solution

So I have a 2d array that z = f(x,y) that I simply want to fit... it is completely random in shape... but I want to fit it as accurately as possible using

 

z(x,y) = a + bx + cy + dxy + ex^2 + fy^2.

 

Ive tried looking through a few examples provided by altenbach including the 2Dpolytruncated.vi and the 3DPolyFitFull3D_12.vi and am unsure of how to implement those given my 2d array of data. If someone could assist in implementing those examples or their own example given my data that would be awesome.

 

Attached find a png of the data sample, and a text file containing the data

 

Download All
0 Kudos
Message 1 of 15
(5,576 Views)

A 2D array is always rectangular and cannot be of arbitrary shape.

 

I am currently on the bus, will look at your this later... Could you attach your VI instead of a fp picture?

0 Kudos
Message 2 of 15
(5,537 Views)

Of course you cannot have NaNs, so rewrite the model to use a 1D array of ((x,y),z) data, where the xy pairs are the indices of valid elements.

0 Kudos
Message 3 of 15
(5,528 Views)

I meant the general shape of the value of z is not a 2d Gaussian or anything like that... its just random data.

 

My VI just produces a 2d array... there isn't much point in posting it... I also cant really post the VI as it has sensitive information that I can't publicly release.... I haven't started attempting the 2d fit because I'm not sure where to begin and how to approach it. I just need to understand how one goes about a multidimensional fit as it confuzzles me.

 

There isn't too much of a rush... I'm focusing on other things today so I won't be applying the fit until Monday... but it would be super awesome to figure out how to do it on Monday lol

0 Kudos
Message 4 of 15
(5,526 Views)

So create a 1d array that is as follows...

(x1, y1, z1, x2, y1, z2, x3, y1, z3........etc)? and then fit that using the 1D non-linear curve fit VI? of course I can just filter out the NaNs no problem.

0 Kudos
Message 5 of 15
(5,523 Views)

Of course you should use "general linear fit". Just set up the matrix. Your function is linear in all coefficients!

0 Kudos
Message 6 of 15
(5,522 Views)

@Jewsus wrote:

So create a 1d array that is as follows...

(x1, y1, z1, x2, y1, z2, x3, y1, z3........etc)? and then fit that using the 1D non-linear curve fit VI? of course I can just filter out the NaNs no problem.


You cannot fit "that" because it contains independent and dependent parameters.

0 Kudos
Message 7 of 15
(5,518 Views)

What do you mean my function is linear in coefficients... I apologize for not understanding... been an awfully long exhausting week

0 Kudos
Message 8 of 15
(5,515 Views)

Still on the bus. I'll make a quick example later if I have time.

0 Kudos
Message 9 of 15
(5,511 Views)

I'm just not understanding how I should be building that array then.... thanks a lot for taking the time to help. When you get home, could you post an example of what you mean? I feel like visually seeing it will help it all come together for moi

0 Kudos
Message 10 of 15
(5,510 Views)