LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fitting a surface (height=f(x,y) with a least square fit

I would like to remove the best plane or sphere from a surface defined by a 2D array. Is there a simple way to do this with Labview?
0 Kudos
Message 1 of 16
(7,316 Views)
For a sphere, you can use the Fitting on a Sphere.vi (in the Analyse>Mathematics>Optimization).

CC
Chilly Charly    (aka CC)
0 Kudos
Message 2 of 16
(7,307 Views)
Could you repeat the question, it is too ambiguous.

What do you want to "remove"? Are you talking about masking a circular area?

Is your 2D array a (2,x) array, wich each row describing the x,y coordinates of a point? In this case, you can only do a circle because there is no 3rd dimension.

Do you have a full 2D grid with values representing the z-direction (similar to an intensity graph)? In this case, you can probably fit to e.g. a half-sphere after you define the the points belonging to it. As CC mentioned, fitting on a sphere should do the trick.

Attach an example of your data and we can help further.
0 Kudos
Message 3 of 16
(7,297 Views)
Hi, Altenbach !
I interpreted "remove" as "retrieve" or "recover". The kind of error a foreigner can do...

Now, I forgot my maths to fit a "least-square" plane to a XYZ data series.
Can you help me back on the track, please ?

CC
Chilly Charly    (aka CC)
0 Kudos
Message 4 of 16
(7,284 Views)
Hi,
I try to explain my problem again (you're right english is not my native language!).
Height data (z(x,y)) are described by a 2D-array and is similar to what you call "intensity graph". The X and Y coordinates are defined by the index of column and row respectively. What I would like to do is to find the best plane (or sphere) fitting the surface and to substract it from z data to obtain residuals (tilt of the surface or curvature substracted).
In fact I'm looking for doing the same as "General Polynomial Fit.VI" applied to a 2D-array.
Thanks,
0 Kudos
Message 5 of 16
(7,273 Views)
Hi,

I tried to apply polynormial fitting on the x direction and then the y direction. It makes the surface smooth. Check out the attached example (Surface Fitting.vi).

I remember I happened to see somebody using Levenberg-Marquardt method to fit a surface but can't find the link. Forfunately, I found the VI in my computer and have attached it. This method does well if you have a model for the surface known.
Message 6 of 16
(7,268 Views)
Levenberg-Marquardt method. Thanks to the owner of these VIs. 🙂
Message 7 of 16
(7,267 Views)
Thanks for your help.
2DQuadraticPalneFit.vi is exactly what I was looking for.
Thanks also to C.ALTENBACH the author of these VIs.
0 Kudos
Message 8 of 16
(7,261 Views)
Hey, cool. I thought I recognized that 2D surface fit ;). (Maybe one of these days I should submit it to the example code library here on ni.com...)

My green Lev-Mar subVIs are a dramatic improvement in functionality over the stock Vis where the function needs to be called one point at a time. (These are actually highly simplified, my latest internal versions are much more universal and can do all kinds of tricks :))

Levenberg-Marquardt is definitely the way to go if you want to subtract an arbitrary 2D background surface from your data.

IF your data really is an exactly spherical surface as you (maybe?) first hinted, it would be much more efficient to use the "fitting on a sphere". It uses a very interesting algorithm that reduces the problem to a simple linear equation (see the online help). I made a quick demo last night while watching news. For simplicity, it assumes that the center of the sphere is at z=0, modify as needed. (See attached, LabVIEW 7.1)

Message Edited by altenbach on 03-24-2005 08:51 AM

Message 9 of 16
(7,247 Views)

Hi

 

comming back to this old topic...

 

I would like to fit a set of data points with a GIVEN surface in which coefficients are unknown.

 

Basically i have data out of a sensor that is dependent on humidity and temperature and SHOULD follow this equation:

 

RH = a0*T*x + a1*x + b0*T + b1

 

Where RH is humidity, T is temperature and x is the data output. My data set includes the variables RH, T and x.

 

I would like to calculate a0, a1, b0 and b1. However, Labview offers linear fitting and the non linear fitting is, as far as i understand) limitted to given general functions (so, i can not fit my own function).

 

Any sugestion?

 

Thanks in advance!

0 Kudos
Message 10 of 16
(6,042 Views)