Solve system of differntial equation with one variable

조회 수: 1 (최근 30일)
dydt= f(t,y)
t=0:0.0.1:1;
dydt(1) = ( 1.15125859*10^-17)*1i;
dydt(2) = ( 2.77307307*10^-17)*1i;
dydt(3) = ( 8.3780271*10^-17)*1i;
  댓글 수: 1
Akhilkrishna Panamkoottathil Ramakrishnan
How can i solve these 3 quations . Also i want to find how y1,y2,y3 varies from t=0 to t=1;

댓글을 달려면 로그인하십시오.

답변 (1개)

Piotr Balik
Piotr Balik 2021년 1월 3일
One easy way to solve ODE's is using ode45 solver.
Define your derivative function in separate file, just as in your question:
function dydt = myODE(t,y)
dydt(1) = (1.15125859*10^-17)*1i;
dydt(2) = (2.77307307*10^-17)*1i;
dydt(3) = (8.3780271*10^-17)*1i;
end
And call for the solver:
t=0:0.01:1;
initial=[0 0 0]'; %column form
[t,y]=ode45(@myODE,t,initial);
%visualize
plot(t,y)
  댓글 수: 4
Star Strider
Star Strider 2021년 1월 4일
Change the function to:
function dydt = myODE(t,y)
dydt = zeros(3,1);
dydt(1) = (1.15125859*10^-17)*1i;
dydt(2) = (2.77307307*10^-17)*1i;
dydt(3) = (8.3780271*10^-17)*1i;
end
That will produce a column vector (the default is a row vector), and the code should work.
Akhilkrishna Panamkoottathil Ramakrishnan
The code worked.
But i got a warning, "complex parts of imaginary numbers x and y are ignored ".
Also all the results are.
Actually from the above 3 equations, i want to find y1,y2,y3. where t varies from 0 to1.
Can anyone help?
Thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by