Baixe o app para aproveitar ainda mais
Prévia do material em texto
Algoritmo Ajustamento de Curvas h=//número de pontos experimentais x=[; ; ; ; ];//coordenadas dos pontos experimentais f=[ ; ; ; ; ];//valores da função nos pontos experimentais n=//número de funções g / ordem -1 da curva de ajuste function [g,ge]=funcaog(x,n,h) p=poly(0,"x") for i=1:n for j=1:h g(i,j)=x(j)^(i-1) end ge(i)=p^(i-1) end endfunction function [A,ge]=adeterminar(x,n,h) [g,ge]=funcaog(x,n,h) for k=1:n for j=k:n A(k,j)=0; for i=1:n A(k,j)=A(k,j)+((g(k,i))*(g(j,i))); end A(j,k)=A(k,j); end end for j=1:n B(j)=0 for i=1:n B(j)=B(j)+((f(i))*(g(j,i))); end end for i=1:n A(i,n+1)=B(i); end endfunction function [A,M]=escalonar(M,n) A=M pivots=n-1 m=n+1 for i=1:pivots Mmax=0.0; for k=i:n termo=M(k, i); if 0>termo then termo=-termo; end if termo>Mmax then Mmax=termo; L=k; end end if i~=L then for j=1:m prov=M(i, j); M(i, j)=M(L, j); M(L, j)=prov; prov=A(i,j); A(i,j)=A(L,j); A(L,j)=prov; end end pivot=M(i, i); prox= i+1; for j=prox:n const= M(j, i)/pivot; for k=i:m M(j, k)=M(j, k)-const*M(i, k); end end end endfunction function X=solucao(M,n) m=n+1 for i=1:n rev=n+1-i; y=M(rev,m); if n~=rev then for j=2:i k=m+1-j; y=y-M(rev,k)*X(k); end end X(rev)=y/M(rev,rev); end endfunction function pol=poli(ge,a,n) pol=0; for i=1:n pol=pol+a(i)*ge(i); end endfunction pol� Exemplo - Queda de um elevador Movimento suposto: queda livre -->h=5; -->x=[0;1;2;3;4]; -->f=[1100;1084;1036;956;844]; -->n=3; -->exec('C:\Users\Matheus\Documents\funcaog.sci', -1) -->exec('C:\Users\Matheus\Documents\adeterminar.sci', -1) -->[A,ge]=adeterminar(x,n,h) ge = 1 x x² A = 3. 3. 5. 3220. 3. 5. 9. 3156. 5. 9. 17. 5228. -->exec('C:\Users\Matheus\Documents\escalonar.sci', -1) -->[A,M]=escalonar(A,n) M = 5. 9. 17. 5228. 0. - 2.4 - 5.2 83.2 0. 0. - 0.3333333 5.3333333 A = 5. 9. 17. 5228. 3. 3. 5. 3220. 3. 5. 9. 3156. -->exec('C:\Users\Matheus\Documents\solucao.sci', -1) -->a=solucao(M,n) a = 1100. 1.415D-12 - 16. -->exec('C:\Users\Matheus\Documents\poli.sci', -1) -->pol=poli(ge,a,n) pol = 1100 + 1.415D-12x - 16x² �
Compartilhar