Function with multiple input parameters to be determined through fitting
Hi, I have a function to be fitted to some experimental data, but this function has multiple fitting parameters (6 parameters). I know that one of the ways to find these fitting parameters is to pass the function, the inital guess to the parameters and the lower and upper bounds into the lsqcurvefit function.
I have already created the function, but it seems like the software doesn’t know that the p(1),p(2), p(3)… are parameters. Sorry if the function is very long.
What I wanted was p to be a vector with 6 elements p(1) p(2) p(3) p(4) p(5) p(6) but it seems like the software cant differentiate betwen p and p(1) p(2) p(3) p(4) p(5) p(6). When I try running the code, the error message I got was "Not enough input arguments"
Thank you for helping
function F = EM_SS(p, E_p)
F = p(1)*(2*pi*sqrt(p(4))/E_p)*(1/p(6))*(int(sech(((E_p – E)./p(6)))*(1 + 10*p(5)*(E – p(3)) + 126*p(5)^2*(E – p(3))^2)/(1 – exp(-2*pi*sqrt(p(4)/(E – p(3))))), E, p(3), Inf, ‘ArrayValued’, 1)) + p(2)*(2*pi*p(4)^3/2)*1/p(6)*((1/1^3)*sech((E_p – p(3) + p(4)/1^2)./p(6)) + (1/2^3)*sech((E_p – p(3) + p(4)/2^2)./p(6)) + (1/3^3)*sech((E_p – p(3) + p(4)/3^2)./p(6)) + (1/4^3)*sech((E_p – p(3) + p(4)/4^2)./p(6)) + (1/5^3)*sech((E_p – p(3) + p(4)/5^2)./p(6)) + (1/6^3)*sech((E_p – p(3) + p(4)/6^2)./p(6)) + (1/7^3)*sech((E_p – p(3) + p(4)/7^2)./p(6)));
endHi, I have a function to be fitted to some experimental data, but this function has multiple fitting parameters (6 parameters). I know that one of the ways to find these fitting parameters is to pass the function, the inital guess to the parameters and the lower and upper bounds into the lsqcurvefit function.
I have already created the function, but it seems like the software doesn’t know that the p(1),p(2), p(3)… are parameters. Sorry if the function is very long.
What I wanted was p to be a vector with 6 elements p(1) p(2) p(3) p(4) p(5) p(6) but it seems like the software cant differentiate betwen p and p(1) p(2) p(3) p(4) p(5) p(6). When I try running the code, the error message I got was "Not enough input arguments"
Thank you for helping
function F = EM_SS(p, E_p)
F = p(1)*(2*pi*sqrt(p(4))/E_p)*(1/p(6))*(int(sech(((E_p – E)./p(6)))*(1 + 10*p(5)*(E – p(3)) + 126*p(5)^2*(E – p(3))^2)/(1 – exp(-2*pi*sqrt(p(4)/(E – p(3))))), E, p(3), Inf, ‘ArrayValued’, 1)) + p(2)*(2*pi*p(4)^3/2)*1/p(6)*((1/1^3)*sech((E_p – p(3) + p(4)/1^2)./p(6)) + (1/2^3)*sech((E_p – p(3) + p(4)/2^2)./p(6)) + (1/3^3)*sech((E_p – p(3) + p(4)/3^2)./p(6)) + (1/4^3)*sech((E_p – p(3) + p(4)/4^2)./p(6)) + (1/5^3)*sech((E_p – p(3) + p(4)/5^2)./p(6)) + (1/6^3)*sech((E_p – p(3) + p(4)/6^2)./p(6)) + (1/7^3)*sech((E_p – p(3) + p(4)/7^2)./p(6)));
end Hi, I have a function to be fitted to some experimental data, but this function has multiple fitting parameters (6 parameters). I know that one of the ways to find these fitting parameters is to pass the function, the inital guess to the parameters and the lower and upper bounds into the lsqcurvefit function.
I have already created the function, but it seems like the software doesn’t know that the p(1),p(2), p(3)… are parameters. Sorry if the function is very long.
What I wanted was p to be a vector with 6 elements p(1) p(2) p(3) p(4) p(5) p(6) but it seems like the software cant differentiate betwen p and p(1) p(2) p(3) p(4) p(5) p(6). When I try running the code, the error message I got was "Not enough input arguments"
Thank you for helping
function F = EM_SS(p, E_p)
F = p(1)*(2*pi*sqrt(p(4))/E_p)*(1/p(6))*(int(sech(((E_p – E)./p(6)))*(1 + 10*p(5)*(E – p(3)) + 126*p(5)^2*(E – p(3))^2)/(1 – exp(-2*pi*sqrt(p(4)/(E – p(3))))), E, p(3), Inf, ‘ArrayValued’, 1)) + p(2)*(2*pi*p(4)^3/2)*1/p(6)*((1/1^3)*sech((E_p – p(3) + p(4)/1^2)./p(6)) + (1/2^3)*sech((E_p – p(3) + p(4)/2^2)./p(6)) + (1/3^3)*sech((E_p – p(3) + p(4)/3^2)./p(6)) + (1/4^3)*sech((E_p – p(3) + p(4)/4^2)./p(6)) + (1/5^3)*sech((E_p – p(3) + p(4)/5^2)./p(6)) + (1/6^3)*sech((E_p – p(3) + p(4)/6^2)./p(6)) + (1/7^3)*sech((E_p – p(3) + p(4)/7^2)./p(6)));
end curve fitting, lsqcurvefit MATLAB Answers — New Questions