Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- load temperatura.dat
- M = length(temperatura);
- time = temperatura(:, 1);
- Y = temperatura(:, 2);
- t_min = temperatura(1,1);
- t_max = temperatura(M,1);
- A = ones(M,3);
- A(:,2) = cos(2*pi*(time-t_min)/(t_max-t_min));
- A(:,3) = sin(2*pi*(time-t_min)/(t_max-t_min));
- X = (A'*A)\(A'*Y)
- curva = X(1)+X(2)*A(:,2)+X(3)*A(:,3);
- plot(time,Y,'c.',time,curva, 'k');
- legend('Dados amostrados','Função aproximada pelo métodos dos mínimos quadrados');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement