Hi guys!
I need help with a least square method fit for the model function a*cosh(b*x)+c but im not sure how to do it without the curve fitting tool (see solution of code below). I am not sure have to split the a and b or the cosh(b*x) to create a matrix and use the A\y backslash command in matlab to get the variables of a b and c. I tried putting b as 1 to solve it but i dont think i get the right answer (se code below the %curve fitting tool)
I was given 15 different points (x,y).
% Curve fitting tool <-- This should be right i guess
% g = fittype('a*cosh(b*x) + c','coeff',{'a','b','c'});
% options = fitoptions(g);
% fitobject = fit(x',y',g,options);
% fit3 = (fitobject.a)*cosh((fitobject.b)*x) + fitobject.c;
% Without the curve fitting tool <-- Probably wrong
x=[ . . . . . . . . . . . . . . .]y=[ . . . . . . . . . . .. . . .]x=cosh(1*x)';A=[cosh(x) ones(size(x))]ab=A\yn2=[]for i=1:15 n=ab(1)*x(i)+ab(2); n2(i)=n;endplot(x,n2,'ro')
Do you have any clues on how to solve this one without the curve fitting tool?
I would be really greatful if you can help me with this one!
Best Answer