I have this set of data
x=[0:0.01:1];y=4- 3*x + sin(x*6*pi) + rand(1,101)/8;plot(x,y,'ko','MarkerFaceColor','k');
and want to do a fit using fminsearch
hold onb0=[2,-2,2,5];b=fminsearch(@(b) doamne(b,x,y), b0);yfit= b(1)+ b(2)*x + b(3)*sin(x*pi*b(4));plot(x,yfit, '-b')hold off
where
function d2=doamne(b,x,y)c2=y- (b(1)+ b(2)*x)d2=sum(c2.^2)
but I keep getting this error: "Undefined function 'doamne' for input arguments of type 'double'." I double checked that all my files are in the working folder and that the working folder is in the path list but the error persists.
Best Answer