Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function[] = mmq(fi, valor)
- % paulogp
- % metodo dos minimos quadrados
- disp(' ');
- matrix= importdata('mmq_tabela.m', '\t');
- p = matrix(:, 1)';
- f = matrix(:, 2)';
- syms x;
- n = length(p);
- m = length(fi);
- c = zeros(m, m);
- b = zeros(m, 1);
- for i=1:n
- for j=1:m
- for k=j:m
- c(k, j) = c(k, j) + subs(fi(k), p(i))*subs(fi(j), p(i));
- c(j, k) = c(k, j);
- end
- b(j) = b(j)+f(i)*subs(fi(j),p(i));
- end
- end
- a = b\c;
- aStr = mat2str(a);
- disp(['Resultado = ' aStr]);
- disp(' ');
- end
- % ficheiro: mmq_tabela.m
- 1.00 1.017452
- 1.05 0.971622
- 1.10 0.930208
- 1.15 0.892646
- 1.20 0.858464
- 1.25 0.827269
- 1.30 0.798724
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement