help solve odefcn with time dependence
Afficher commentaires plus anciens
Hi,
Can you please help me solve my problem with this 16 coupled diffrential equation ? With Jkl-all time dependent series of size (1,991).
Thank you very much!
function dydt = odecdn(t,x,A,U,J,N)
q1= real(angle(conj(A(:,3)).*A(:,1))./(abs(A(:,1)).*sqrt(N-abs(A(:,1)).^2-abs(A(:,2)).^2)));
q2= real(angle(conj(A(:,3)).*A(:,2))./(abs(A(:,1)).*sqrt(N-abs(A(:,2)).^2-abs(A(:,2)).^2)));
p1 = (abs(A(:,1))).^2;
p2 = (abs(A(:,2))).^2;
J11= transpose(real(sqrt(p2./p1).*sin(q2-q1).*(-J/2)));
J12= transpose(real((-J/2)*(-sqrt(p2./p1).*sin(q2-q1)+ sqrt((p2)./(N-p1-p2)).*sin(q2))));
J13= transpose(real((-J/2).*(cos(q2-q1).*sqrt(p2).*(-0.5).*p1.^(-3.2) - cos(q2).*sqrt(p2).*(-0.5).*(N-p1-p2).^(-3/2).*(-1))+2.*U));
J14= transpose(real(0.5.*(p2).^(-0.5).*(p1).^(-0.5).*cos(q2-q1)-(0.5*(p2/(N-p1-p2)).^(-0.5).*cos(q2).*(((N-p1))./((N-p1-p2).^2))) + U));
J21= transpose(real((-J/2).*sin(q2-q1)));
J22= transpose(real((-J/2).*(-sin(q2-q1)+sin(q2).*((N-p1-2.*p2)./(sqrt(p2.*(N-p1-p2)))))));
J23= transpose(real((-J/2).*(-cos(q2).*((-sqrt(p2.*(N-p1-p2))-0.5.*(p2.*(N-p1-p2)).^(-3./2).*(N-p1-2.*p2))./(p2.*(N-p1-p2))))+U));
J24= transpose(real((-J/2).*(-(-2.*sqrt(p2.*(N-p1-p2))-(0.5.*cos(q2).*(N-p1-2.*p2).*(p2.*(N-p1-p2)).^(-3./2))))+2.*U));
J31= transpose(real(-J*sqrt(p1.*p2).*cos(q1-q2)));
J32= transpose(real(J*sqrt(p1.*p2).*cos(q1-q2)));
J33= transpose(real(-J*0.5.*sqrt(p2).*(p1).^(-0.5).*sin(q1-q2)));
J34= transpose(real(-0.5.*J*sqrt(p1).*(p2).^(-0.5).*sin(q1-q2)));
J41= transpose(real(J*sqrt(p1.*p2).*cos(q1-q2)));
J42= transpose(real(J*(-sqrt(p1.*p2).*cos(q1-q2)+sqrt(p2.*(N-p1-p2)).*cos(q2))));
J43= transpose(real(J*(sqrt(p2).*0.5.*p1.^(-0.5).*sin(q1-q2)+sin(q2).*0.5.*(p2.*(N-p1-p2)).^(-0.5))));
J44= transpose(real(J*(sqrt(p1).*0.5.*(p2).^(-0.5).*sin(q1-q2)-sin(q2).*0.5.*(p2.*(N-p1-p2)).^(-0.5).*(-p1-2.*p2))));
dydt=zeros(9991,9991)
y=zeros(16,9991)
dydt(1)= (J11.*(y(1))+ (J12).*(y(5))+(J13).*(y(9))+(J14).*(y(13)));
dydt(2)= J11.*(y(2))+ (J12).*(y(6))+(J13).*(y(10))+(J14).*(y(14));
dydt(3)= (J11.*(y(3))+ J12.*(y(7))+J13.*(y(11))+J14.*(y(15)));
dydt(4)= (J11.*(y(4))+ J12.*(y(8))+J13.*(y(12))+J14.*(y(16)));
dydt(5)= (J21.*(y(1))+ J22.*(y(5))+J23.*(y(9))+J24.*(y(13)));
dydt(6)= (J21.*(y(1))+ J22.*(y(5))+J23.*(y(9))+J24.*(y(13)));
dydt(7)= (J21.*(y(3))+ J22.*(y(7))+J23.*(y(11))+J24.*(y(15)));
dydt(8)= (J21.*(y(4))+ J22.*(y(8))+J23.*(y(12))+J24.*(y(16)));
dydt(9)= (J31.*(y(1))+ J32.*(y(5))+J33.*(y(9))+J34.*(y(13)));
dydt(10)= (J31.*(y(2))+ J32.*(y(6))+J33.*(y(10))+J34.*(y(14)));
dydt(11)= (J31.*(y(3))+ J32.*(y(7))+J33.*(y(11))+J34.*(y(15)));
dydt(12)= (J31.*(y(4))+ J32.*(y(8))+J33.*(y(12))+J34.*(y(16)));
dydt(13)= (J41.*(y(1))+ J42.*(y(5))+J43.*(y(9))+J44.*(y(13)));
dydt(14)= (J41.*(y(2))+ J42.*(y(6))+J43.*(y(10))+J44.*(y(14)));
dydt(15)= (J41.*(y(3))+ J42.*(y(7))+J43.*(y(11))+J44.*(y(15)));
dydt(16)= (J41.*(y(4))+ J42.*(y(8))+J43.*(y(12))+J44.*(y(16)));
end
1 commentaire
Torsten
le 19 Nov 2022
The number of differential equations and the number of unknown functions must be the same.
Since you initialize
dydt=zeros(9991,9991)
y=zeros(16,9991)
you seem to have 16*9991 unknown functions and 9991*9991 differential equations.
This is not solvable.
Réponse acceptée
Plus de réponses (2)
Hélène De Witte
le 19 Nov 2022
Modifié(e) : Hélène De Witte
le 19 Nov 2022
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!