Bonsoir,
Pourriez vous m'aidez a trouver l'erreur afin d'exécuter un programme dans Matlab de la méthode Rung Kutta d'ordre 4 qui permet de tracer la trajectoire de la lumière dans une fibre optique.
Voici le code
merci beaucoupCode:%Programme Rung Kutta 4 appliqué à la Fibre Optique% function [xx,yy,zz]=RK4(x,y,z,h,phi,theta,N) xx[1]=x; yy[1]=y; zz[1]=z; t1=(sin(theta*pi/180))*(cos(phi*pi/180)); t2=(sin(theta*pi/180))*(sin(phi*pi/180)); t3=cos(theta*pi/180); for i=2:1000 i1=t1; k1=t2; m1=t3; j1=(2*(-x+i1*(x*i1+y*k1)))/((2*p*p)-(x*x)-(y*y)); l1=(2*(-y+k1*(x*i1+y*k1)))/((2*p*p)-(x*x)-(y*y)); n1=(2*(m1*(x*i1+y*k1)))/((2*p*p)-(x*x)-(y*y)); i2=t1+(j1*(h/2)); k2=t2+(l1*(h/2)); m2=t3+(n1*(h/2)); j2=(2*((-(x+(i1*h/2)))+i2*((x+(i1*h/2))*i2+((y+(k1*h/2))*k2))))/((2*p*p)-(x*x)-(y*y)); l2=(2*((-(y+(k1*h/2)))+k2*((x+(i1*h/2))*i2+((y+(k1*h/2))*k2))))/((2*p*p)-(x*x)-(y*y)); n2=(2*(m2*((x+(i1*h/2))*i2+((y+(k1*h/2))*k2))))/((2*p*p)-(x*x)-(y*y)); i3=t1+(j2*(h/2)); k3=t2+(l2*(h/2)); m3=t3+(n2*(h/2)); j3=(2*((-(x+(i2*h/2)))+i3*((x+(i2*h/2))*i3+((y+(k2*h/2))*k3))))/((2*p*p)-(x*x)-(y*y)); l3=(2*((-(y+(k2*h/2)))+k3*((x+(i2*h/2))*i3+((y+(k2*h/2))*k3))))/((2*p*p)-(x*x)-(y*y)); n3=(2*(m3*((x+(i2*h/2))*i3+((y+(k2*h/2))*k3))))/((2*p*p)-(x*x)-(y*y)); i4=t1+(j3*h); k4=t2+(l3*h); m4=t3+(n3*h); j4=(2*((-(x+(i3*h)))+i4*((x+(i3*h))*i4+(y+(k3*h))*k4) ))/((2*p*p)-(x*x)-(y*y)); l4=(2*((-(y+(k3*h)))+k4*((x+(i3*h))*i4+(y+(k3*h))*k4) ))/((2*p*p)-(x*x)-(y*y)); n4=(2*(m4*((x+(i3*h))*i4+(y+(k3*h))*k4)))/((2*p*p)-(x*x)-(y*y)); x =x +h*((i1+2*i2+2*i3+i4)/6); y =y +h*((k1+2*k2+2*k3+k4)/6); z =z +h*((m1+2*m2+2*m3+m4)/6); t1=t1+h*((j1+2*j2+2*j3+j4)/6); t2=t2+h*((l1+2*l2+2*l3+l4)/6); t3=t3+h*((n1+2*n2+2*n3+n4)/6); xx[i]=x; yy[i]=y; zz[i]=z; end
-----