1 / 3

function [x]=pointmilieu(a,t,f) N=length(t); n=length(a); x=zeros(n,N); x(:,1)=a; for i=2:N

function [x]=pointmilieu(a,t,f) N=length(t); n=length(a); x=zeros(n,N); x(:,1)=a; for i=2:N h=t(i)-t(i-1); x(:,i)=x(:,i-1)+h*f(t(i-1)+.5*h,x(:,i-1)+.5*h*f(t(i-1),x(:,i-1))); end endfunction. function tracemilieu(a,t) getf vdp.sci getf pointmilieu.sci x=pointmilieu(a,t,vdp);

inez
Télécharger la présentation

function [x]=pointmilieu(a,t,f) N=length(t); n=length(a); x=zeros(n,N); x(:,1)=a; for i=2:N

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. function [x]=pointmilieu(a,t,f) N=length(t); n=length(a); x=zeros(n,N); x(:,1)=a; for i=2:N h=t(i)-t(i-1); x(:,i)=x(:,i-1)+h*f(t(i-1)+.5*h,x(:,i-1)+.5*h*f(t(i-1),x(:,i-1))); end endfunction function tracemilieu(a,t) getf vdp.sci getf pointmilieu.sci x=pointmilieu(a,t,vdp); y=ode(a,t(1),t,vdp); plot(x(1,:),x(2,:),'g',y(1,:),y(2,:),'b'); endfunction function [y]=vdp(t,x) y=zeros(2,1); y(1)=x(2); y(2)=.4*(1-x(1)*x(1))*x(2)-x(1); endfunction

  2. function traceRK4(a,t) getf RK4.sci getf vdp.sci x=RK4(a,t,vdp); y=ode(a,t(1),t,vdp); plot(x(1,:),x(2,:),'g',y(1,:),y(2,:),'b'); endfunction function [x]=RK4(a,t,f) N=length(t); n=length(a); x=zeros(n,N); x(:,1)=a; for i=2:N h=t(i)-t(i-1); k0=h*f(t(i-1),x(:,i-1)); k1=h*f(t(i-1)+.5*h,x(:,i-1)+k0*.5); k2=h*f(t(i-1)+.5*h,x(:,i-1)+k1*.5); k3=h*f(t(i-1)+h,x(:,i-1)+k2); x(:,i)=x(:,i-1)+(k0+2*k1+2*k2+k3)/6; end endfunction

  3. function [x] = bashforth(x0,x1,t0,t1,N,f) n=length(x0); t=linspace(t0,t1,N); x=zeros(n,N); x(:,1)=x0; x(:,2)=x1; for i=3:N h=t(i)-t(i-1) x(:,i)=x(:,i-1)+ h*(3*f(t(i-1),x(i-1))-f(t(i-2),x(i-2)))/2; end endfunction function tracebash(x0,t) getf bashforth.sci getf vdp.sci N=length(t); t0=t(1); t1=t(N); h0=t(2)-t(1); x1=x0+h0*vdp(t(1)+.5*h0,x0+.5*h0*vdp(t(1),x0)); x=bashforth(x0,x1,t0,t1,N,vdp); y=ode(a,t(1),t,vdp); plot(x(1,:),x(2,:),'g',y(1,:),y(2,:),'b'); endfunction

More Related