Least square fitting - lsqcurvefit - multiple equations - not enough input arguments -
Afficher commentaires plus anciens
Hello everyone,
I am trying to fit some experimental data to a cerain model,
my data:
x_exp = [0.109112654
0.174029442
0.2775686
0.442708583
0.706098923
1.126193863
1.796225113
2.864892769
4.569366345
7.28791982
];
y_exp = [5247.044317
8170.755912
12604.15367
19261.43738
29160.90041
42700.48525
63815.24278
95016.30828
140804.9657
207196.2571
];
i want to fit this data using lsqcurvefit, but the problem is my model is not a one line code, it is contructed as follows, it has 4 parameters, o is the variable and my final output is G, i want to fit my y_exp with G:
% parameters are k , tau , Gg , G0
A = (o*tau)^-k * cos (k*pi/2);
B = (o*tau)^-k * sin (k*pi/2);
G1 = G0 + (((Gg-G0)* (1+A))/ (((1+A)^2)+B^2));
G2 = ((Gg-G0)* (-B)/ (((1+A)^2)+B^2));
G = ((G1^2 + G2^2)^0.5);
when i used lsqcurvefit, i constructed the code as follows, but i keep getting a message (Not enough input arguments):
% define A & B
A = @(x,xdata)(xdata*x(2))^-x(1) * cos (x(1)*pi/2);
B = @(x,xdata)(xdata*x(2))^-x(1) * sin (x(1)*pi/2);
% Define G' & G''
G1 = @(x,xdata)x(4) + (((x(3)-x(4))* (1+A(x)))/ (((1+A(x))^2)+B(x)^2));
G2 = @(x,xdata)((x(3)-x(4))* (-B(x))/ (((1+A(x))^2)+B(x)^2));
% Define G
G = @(x,xdata)((G1(x)^2 + G2(x)^2).^0.5);
x0 = [0.5 1E-4 1E+7 1E-5];
[x,resnorm,~,exitflag,output] = lsqcurvefit(G,x0,x_exp,y_exp)
can any one please help me with this?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
