Hello everyone,
I am trying to fit some experimental data to a cerain model,
my data:
x_exp = [0.1091126540.1740294420.27756860.4427085830.7060989231.1261938631.7962251132.8648927694.5693663457.28791982];y_exp = [5247.0443178170.75591212604.1536719261.4373829160.9004142700.4852563815.2427895016.30828140804.9657207196.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?
Best Answer