Sie sind auf Seite 1von 2

unction [Y2] =sistema2(a,b)

%UNTITLED18 Summary of this function goes here


% Detailed explanation goes here
Y2=4-0.3*b-0.1*a;
end


function [Y1] =sistema1(a)
%UNTITLED17 Summary of this function goes here
% Detailed explanation goes here
Y1=-0.5*a;

end


SISTEMA DE ECUACIONES EULER 2POR 2

clc;
clear all;
x0=0;
xf=10;
a0=4;
b0=6;
h=0.5;
N=(xf-x0)/h;
ite=0;
for ite=1:N
y1=a0+h*sistema1(a0);
y2=b0+h*sistema2(a0,b0);
a0=y1;
b0=y2;
x0=x0+h;
fprintf('%4.0f %4.5f %4.4f %4.5f\n',ite,x0,y1,y2);
end

RUGEN KUTTA 4TO ORDEN SISTEMA DE 2POR 2
unction [Y2] =sistema2(a,b)
%UNTITLED18 Summary of this function goes here
% Detailed explanation goes here
Y2=4-0.3*b-0.1*a;
end


function [Y1] =sistema1(a)
%UNTITLED17 Summary of this function goes here
% Detailed explanation goes here
Y1=-0.5*a;

clc;
clear all;
x0=0;
xf=10;
a0=4;
b0=6;
h=0.5;
N=(xf-x0)/h;
for ite=1:N
k1=sistema1(a0);
k2=sistema1(a0+(h*k1/2));
k3=sistema1(a0+(h*k2/2));
k4=sistema1(a0+h*k3);
c1=sistema2(a0,b0);
c2=sistema2(a0+h/2,b0+(h*c1/2));
c3=sistema2(a0+h/2,b0+(h*c2/2));
c4=sistema2(a0+h,b0+h*c3);
y1=a0+(h*(k1+2*k2+2*k3+k4)/6);
y2=b0+(h*(c1+2*c2+2*c3+c4)/6);
x0=x0+h;
a0=y1;
b0=y2;
fprintf('%4.0f %4.1f %4.6f %4.6f\n',ite,x0,y1,y2);
i(ite)=y1;
j(ite)=y2;
n(ite)=x0;
end
grid on
hold on
plot(n,i)
hold on
plot(n,j)
xlabel('VALOR DE x0')
ylabel('Variacion de y1 and y2')
title('SISTEMA DE ECUACIONES RUNGE KUTTA 4TO ORDEN')

Das könnte Ihnen auch gefallen