08-16-2019 10:59 AM
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
Solved! Go to Solution.
08-16-2019 12:47 PM
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?
08-16-2019 12:51 PM
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.
08-16-2019 12:53 PM
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
08-16-2019 12:56 PM
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.
08-16-2019 12:57 PM
Of course you should use "general linear fit". Just set up the matrix. Your function is linear in all coefficients!
08-16-2019 12:59 PM
@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.
08-16-2019 01:00 PM
What do you mean my function is linear in coefficients... I apologize for not understanding... been an awfully long exhausting week
08-16-2019 01:02 PM
Still on the bus. I'll make a quick example later if I have time.
08-16-2019 01:02 PM
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