[Matlab] Which is the good solution My vs. School - curve fitting?

In summary, Hy wonders which is the good solution for this problem: a nonlinear least square problem or a linear least square problem. Linearization: 1/y = a/x + b substitution: v = 1/y, u = 1/x. Model v = b + a.u. What we did in school: x = [1 2 4 7]; y = [2 1 0.4 0.1]; v=1./y; u=1./x. Beta0 = flipud(btr)' beta = fminsearch('mnsNLcFUN',beta0) r = [mnsNLcFUN(beta0), mnsNLcFUN(beta)]
  • #1
artiny
7
0
Hy, I wonder which is the good solution for this problem:

Nonlinear least square problem: function: y = x / (a + b.x) linearization: 1/y = a/x + b substitution: v = 1/y , u = 1/x >> model v = b + a.u

What we did in school:

x = [1 2 4 7]; y = [2 1 0.4 0.1];
v=1./y;
u=1./x;
n = length(x);
A=[ones(n,1), u']
xbeta=A\v'
Lbeta=xbeta;
beta0=flipud(Lbeta)
beta=fminsearch('kritfun',beta0)
r = [kritfun(beta0) , kritfun(beta)]


+ kritfun.m

function z=kritfun(beta)
a=beta(1);
b=beta(2);
x = [1 2 4 7];
y = [2 1 0.4 0.1];
error = y - x./(a + b*x );
z = sum((error .^2 ));


in ML we get : xbeta =

7.3658
-8.1692
beta =

1.0e+014 *

-8.2085
4.1043
r =

11.0600 4.1700

but when I try in Curve Fitting tool too check the soulution , I get something else ..according to this video:
too call CF I typed to prompt >>cftool

When I try this I get the same number like in the Curve fitting tool , the a,b parameters is my beta(1),beta(2) and the SSE number is my r(2) ..what was same when I tried this:

x = [1 2 4 7];
y = [2 1 0.4 0.1];

%u = 1./x; %these u and v I don't use it...but I didnt know when not using substituion is correct the beta and r(2) , but when I didnt use I get same numbers lik in the Curve Fitting tool
%v = 1./y;

n = length(x);
X = [ ones(n,1), x'];
btr = X\y'

beta0 = flipud(btr)'
beta = fminsearch('mnsNLcFUN',beta0)
r = [mnsNLcFUN(beta0), mnsNLcFUN(beta)]


+ mnsNLcFUN.m function is:

function z=mnsNLcFUN(beta)
a=beta(1);
b=beta(2);

x = [1 2 4 7];
y = [2 1 0.4 0.1];

error = y - x./(a+b.*x);
z = sum((error .^2 ));
 
Physics news on Phys.org
  • #2
Thanks for the post! Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post?
 
  • #3
somewho said that is more possible way to do the linearization...and what we did is not the same as Matlab makes ,...or I don't know what else..
 

1. How do I know which curve fitting method to use in Matlab?

The best solution for curve fitting in Matlab depends on the specific data and problem you are trying to solve. It is recommended to try multiple methods and compare the results to determine the most accurate fit.

2. What is the difference between the My and School curve fitting solutions in Matlab?

The "My" solution refers to a custom or personal approach to curve fitting, while the "School" solution typically refers to a standard or textbook method. It is important to understand both approaches and choose the one that best suits your data and goals.

3. Can I trust the results of the curve fitting solution in Matlab?

The accuracy of the curve fitting solution in Matlab depends on the quality and quantity of the data being analyzed. It is always recommended to validate the results and compare them to other methods to ensure the best fit.

4. Is there a specific function or tool in Matlab for curve fitting?

Yes, Matlab has a built-in function called "curve fitting toolbox" that offers various methods and tools for curve fitting. It is a useful resource for beginners and experts alike.

5. How do I interpret the results of the curve fitting solution in Matlab?

The results of the curve fitting solution in Matlab typically include a fitted curve, coefficients, and statistics such as the goodness of fit and confidence intervals. It is important to understand these values and how they relate to your data to properly interpret the results.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
999
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
875
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
126
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
955
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
Back
Top