7.29

4
7.29.- Resuelva el siguiente PVI con el método de Runge-Kutta de cuarto orden: ANTONIO NIEVES dy dx =z ¿ y ( 0 ) =1 y ( 1 )=? } PVI dz dx = y ¿ z ( 0 )=−1 z ( 1) =¿ h=0.1 } PVI EN MATLAB: clc, clear all, close all format compact %% INGRESO syms x y z xp1 xp2 yp1 zp1 yp2 zp2 yp3 zp3 fprintf('\n\n') f1=input(' Ingrese la función dy/dx = '); f2=input(' Ingrese la función dz/dx = '); x0 = input(' Ingrese el valor inicial de x, x(0) = '); y0 = input(' Ingrese el valor inicial de y, y(0) = '); z0 = input(' Ingrese el valor inicial de z, z(0) = '); xf = input(' Ingrese el valor final de x, x(f) = '); h= input(' Ingrese el valor de h, h = '); %% MÉTODO DE RUNGE-KUTTA (4TO ORDEN) i=1; n = (xf - x0)/h; g1=subs(f1,{x,y,z},{xp1,yp1,zp1}); g2=subs(f2,{x,y,z},{xp1,yp1,zp1}); m1=subs(f1,{x,y,z},{xp1,yp2,zp2}); m2=subs(f2,{x,y,z},{xp1,yp2,zp2}); n1=subs(f1,{x,y,z},{xp2,yp3,zp3}); n2=subs(f2,{x,y,z},{xp2,yp3,zp3}); xp(1) = x0; yp(1) = y0; zp(1) = z0;

description

matlab

Transcript of 7.29

7.29.- Resuelva el siguiente PVI con el mtodo de Runge-Kutta de cuarto orden: ANTONIO NIEVES

EN MATLAB:

clc, clear all, close allformat compact%% INGRESOsyms x y z xp1 xp2 yp1 zp1 yp2 zp2 yp3 zp3 fprintf('\n\n')f1=input(' Ingrese la funcin dy/dx = ');f2=input(' Ingrese la funcin dz/dx = ');x0 = input(' Ingrese el valor inicial de x, x(0) = ');y0 = input(' Ingrese el valor inicial de y, y(0) = ');z0 = input(' Ingrese el valor inicial de z, z(0) = ');xf = input(' Ingrese el valor final de x, x(f) = ');h= input(' Ingrese el valor de h, h = ');%% MTODO DE RUNGE-KUTTA (4TO ORDEN)i=1;n = (xf - x0)/h; g1=subs(f1,{x,y,z},{xp1,yp1,zp1});g2=subs(f2,{x,y,z},{xp1,yp1,zp1});m1=subs(f1,{x,y,z},{xp1,yp2,zp2});m2=subs(f2,{x,y,z},{xp1,yp2,zp2});n1=subs(f1,{x,y,z},{xp2,yp3,zp3});n2=subs(f2,{x,y,z},{xp2,yp3,zp3});xp(1) = x0; yp(1) = y0;zp(1) = z0;fprintf('\n\t\t\t============================================')fprintf('\n\t\t\t MTODO DE RUNGE-KUTTA (4to Orden)')fprintf('\n\t\t\t============================================')fprintf('\n\t\t\t i x y z')fprintf('\n\t\t\t============================================')fprintf('\n\t\t\t %2d %6.4f %6.4f %6.4f\n',i,xp(1),yp(1),zp(1))while i