Surface fitting to data

Folks,
I have a custom equation with z=a*x*y which I want to fit to some experimental data. The challenge is that
1) The fit z needs to be calculated for 8 different items. For simplicity, we use the same x,y for each item. Then the sum of these 8 items will compared against the experimental data to which I want to fit.
2) Is this possible either through a) SFTOOL and/or B) Programmable approach?
Thanks in advance B

4 Comments

I don't understand what the "8 items" are?
Do you have eight coefficients you're looking for? Please elaborate.
no, not 8 coefficients. The equation z=a*x*y needs to be calculated 8 times and the 8 results are summed for comparison with experimental data for fitting.
So I am guessing that a function would have to be created with a for loop containing this equation but with the x and y values being called from outside of the function...
It needs to be calculated 8 times for the same x and y on each but a different, z?
Yes, there will be 8 different z values. For example Z1=a1.x.y Z2=a2.x.y Zn=an.x.y Z8=a8.x.y
Ztotal to be fitted to experimental data. Is this clearer now? The coefficients an will be constant but different for each z

Sign in to comment.

Answers (2)

Sean de Wolski
Sean de Wolski on 11 Oct 2013
Edited: Sean de Wolski on 11 Oct 2013
The curve/surface fitting tool will work for you application. Design the fit within the application, then go to
File -> Generate Code
This will generate a function that you can then save and call with your new z-data. Each time it will return a fit object based on the new z.
Alternatively, you could use LinearModel.fit in the Statistics Toolbox
doc LinearModel.fit
or lsqcurvefit in the Optimization Toolbox, though this is overkill:
Matt J
Matt J on 11 Oct 2013
Edited: Matt J on 11 Oct 2013
And "a" is the parameter to be fit? sftool seems like overkill for something that can be done as simply as
a=x(:).*y(:)\z(:);

5 Comments

bugatti79
bugatti79 on 11 Oct 2013
Edited: bugatti79 on 11 Oct 2013
No, I think I need the parameters x and y to fit d data if I understand correctly. The coefficients an are constant. Please correct if im wrong. Thanks in advanced B
Matt J
Matt J on 11 Oct 2013
So "a" is known a priori while x and y are to be determined by the fit?
Yes, but I have now just realised that although z is f (x, y) the experimental data is just a 2d plot or curve not a surface.
Im beginning to think its to ambitious!...
On the other hand I can do it in a spreadsheet but obviously its pure guessing trying to fit the curve especially whennvarying two parameters...
The solutions x,y for the equation
z=a*x*y
are not unique. You have 1 equation in 2 unknowns. So your problem appears under-specified.

Sign in to comment.

Categories

Asked:

on 11 Oct 2013

Commented:

on 11 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!