% Initialisation: Function
% Initialisation: Function
% Initialisation: Function
% initialisation
N = (tspan(2)-tspan(1))/pas;
N =fix(N);
narout=length(y0);
yout = zeros(N,narout);
tt = zeros(N,1);
y = y0;
N = 0;
%
for t =tspan(1):pas:tspan(2),
t
K1 = pas * eqdiff(y,t);
K2 = pas * eqdiff(y+0.5*K1,t+0.5*pas);
K3 = pas * eqdiff(y+0.5*K2,t+0.5*pas);
K4 = pas * eqdiff(y+K3,t+pas);
N = N+1;
tt(N,1) = t;
for j=1:narout
yout(N,j) = y(j);
end;
y=y0;
end
clear all;clc
% t initiale et t finale
% pas de calcul
pas = periode/10000;
%-------------------------
%La solution par Runge-Kutta
N=1;
y0=zeros(N,1);
[tr,ii]=Rk4(tspan,pas,y0);
elseif v02>v03
ud(indice)=v2;
vd1(indice)=v1-v2;
else
ud(indice)=v3;
vd1(indice)=v1-v3;
end
end
function dy=eqdiff(y,t)
global R L Vm ws;
v1=Vm*sin(ws*t);
v2=Vm*sin(ws*t-2*pi/3);
v3=Vm*sin(ws*t+2*pi/3);
dy = (ud- R*y)/L;