can anybody help me solve this problem. As I am stuck at the $E(A,B,C,D)=\sum_{k=1}^{24} (f(t_k)-y_k)^2 $ also $E_2 (f)=? $ is the root mean square error
I am having difficulty finding the correct bestfitcurve as I arbitraririly chose initial [A,B,C,D] = [1,1,1,1] and the curve I generated was very sinusoidal. I also used t=linspace(0,2*pi,24) since this is a data within a 24-hour cycle. Here is my octave code
function z=E(u)
x=linspace(0,2*pi,24);
y=[66 66 65 64 63 63 62 61 60 60 59 58 58 58 58 58 57 57 57 58 60 64 67 68];
A=u(1);
C=u(2);
B=u(3);
D=u(4);
z=0;
for i=1:24
z = z+(A*sin(B*x(1,i))+C*cos(D*x(1,i)) - y(1,i))^2;
end
end
P=fmins('E',[1,1,1,1]) P=-1.072785 61.164715 2.844565 0.015377
plot(x, P(1)*sin(P(3)*x) + P(2)*cos(P(4)*x), "-;fun;", x, y, "+;datapts;")
