TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

Códigos MATLAB

Por:   •  24/4/2015  •  Trabalho acadêmico  •  462 Palavras (2 Páginas)  •  331 Visualizações

Página 1 de 2

Método de Euler:

function [p,ve]=euler(t0,tf,h,y0)

% t0 => tempo inicial

% tf => tempo final

% h => passo de integração

% y0 => condição inicial

t=t0;

i=0;

while t<=tf+h,

i=i+1;

p(i)=t;

ve(:,i)=y0;

y=y0+h*fun(t,y0);

t=t+h;

y0=y;

end,

Método de RK2:

function [p,vrk2]=rk2(t0,tf,h,y0)

% t0 => tempo inicial

% tf => tempo final

% h => passo de integração

% y0 => condição inicial

i=1;

p(i)=t0;

v(:,i)=y0;

t=t0;

while t<tf,

k1=fun(t,y0);

k2=fun(t+h,y0+h*k1);

y=y0+(h/2)*(k1+k2);

i=i+1;

t=t+h;

p(i)=t;

vrk2(:,i)=y;

y0=y;

end,

Método de RK4:

function [p,vrk4]=rk4(t0,tf,h,y0)

% t0 => tempo inicial

% tf => tempo final

% h => passo de integração

% y0 => condição inicial

i=1;

p(i)=t0;

v(:,i)=y0;

t=t0;

while t<tf,

k1=fun(t,y0);

k2=fun(t+h/2,y0+(h/2)*k1);

k3=fun(t+h/2,y0+(h/2)*k2);

k4=fun(t+h,y0+(h)*k3);

y=y0+(h/6)*(k1+2*(k2+k3)+k4);

i=i+1;

t=t+h;

p(i)=t;

vrk4(:,i)=y;

y0=y;

end,

Interpolação polinomial:

function [a,k]=interpol(x,y,pr)

%k => número de iterações

%a => vetor coeficientes do polinômio

%x => vetor das abscissas dos

...

Baixar como (para membros premium)  txt (2 Kb)   pdf (42 Kb)   docx (11.8 Kb)  
Continuar por mais 1 página »
Disponível apenas no TrabalhosGratuitos.com