Rk4-problema-propuesto.txt

  • Uploaded by: Edgar Anddy Loarte Pacherres
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Rk4-problema-propuesto.txt as PDF for free.

More details

  • Words: 73
  • Pages: 1
function RK4(f2,a,b,n,y0) %datos %f =el nombre de la funci�n como string %a =limite inferior %b =limite superior %h =longitud del segmento %y0 =f(a) %x =es el vector x %n =numero de segmentos %resultados %y =es el vector f(x) h=(b-a)/n; n=n+1; y=zeros(n,1); x=zeros(n,1); x(1)=a; y(1)=y0; fprintf(' x y \n'); fprintf('====================\n'); fprintf('%10.6f%10.6f\n',x(1),y(1)); for i=1:n-1 k1=feval('f2',x(i),y(i)); k2=feval('f2',x(i)+h/2,y(i)+h*k1/2); k3=feval('f2',x(i)+h/2,y(i)+h*k2/2); k4=feval('f2',x(i)+h,y(i)+h*k3); x(i+1)=a+h*i; y(i+1)=y(i)+h*(k1+2*k2+2*k3+k4)/6; fprintf('%10.6f%10.6f\n',x(i+1),y(i+1)); end

function dydx=f2(x,y) dydx=(y-x-1)^2+2;

>> RK4('f2',0,2,2,1) x y ==================== 0.000000 1.000000 1.000000 3.535848 2.000000520.722026

More Documents from "Edgar Anddy Loarte Pacherres"

Rk4-problema-propuesto.txt
November 2019 8
Informe Previo 1.docx
November 2019 28
November 2019 9
Lamina 1.pdf
November 2019 9
Cristaleriaaaa
May 2020 16