Solve system of differntial equation with one variable
1 回表示 (過去 30 日間)
古いコメントを表示
Akhilkrishna Panamkoottathil Ramakrishnan
2021 年 1 月 2 日
コメント済み: Akhilkrishna Panamkoottathil Ramakrishnan
2021 年 1 月 4 日
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 件)
Piotr Balik
2021 年 1 月 3 日
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
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!