Hi MATLAB users, I have been trying to solve a coupled first order ODE. I want to plot z(t) vs t. the time span from timespan=[0 30]. I would highly appreciate if anyone can guide me. so far I have:
% Constant parameters
DeltaE = 0 ;
omega = 0.1 ;
kesi = 8e-5 ;
Omega = 1e-2 ;
q = 1e-5 ;
% Initial Values
z0 = 0.15 ;
phi0 = (9/5)*pi ;
% undriven
epsilon = 0 ;
%%%driven
%%%epsilon =1e-3 ;
% equations
d(phi)/dt = (omega.*z) + (z./sqrt(1-z.^2)).*q.*cos(phi) + epsilon.*cos(t);
dz/dt = -sqrt(1-z.^2).*1.*sin(phi)+ kesi.*(d(phi)/dt);
Best, Fatemeh

 採用された回答

Torsten
Torsten 2018 年 6 月 20 日

0 投票

% Constant parameters
DeltaE = 0 ;
omega = 0.1 ;
kesi = 8e-5 ;
Omega = 1e-2 ;
q = 1e-5 ;
% Initial Values
z0 = 0.15 ;
phi0 = (9/5)*pi ;
% undriven
epsilon = 0 ;
%%%driven
%%%epsilon =1e-3 ;
fun=@(t,y)[omega*y(2) + y(2)/sqrt(1-y(2)^2)*q*cos(y(1)) + epsilon*cos(t);-sqrt(1-y(2)^2)*sin(y(1))+ kesi*(omega*y(2) + y(2)/sqrt(1-y(2)^2)*q*cos(y(1)) + epsilon*cos(t))];
tspan = [0 30]
y0 = [phi0;z0];
[t,y] = ode45(fun,tspan,y0);
plot(t,y(:,2))
Best wishes
Torsten.

4 件のコメント

fartash2020
fartash2020 2018 年 6 月 20 日
dear Torsten,
I edited the code, does it make any change? the 'z' which you have written as y(2) cannot have values bigger than 1, since it is in "sqrt(1-y(2).^2)". For example I draw the plot for bigger timespan and it increases.
Thank you very much for your answer.
Torsten
Torsten 2018 年 6 月 20 日
If the differential equation itself does not hinder z from becoming greater than 1, you cannot influence it.
fartash2020
fartash2020 2018 年 6 月 20 日
if we change it like this
fun=@(t,y)[(omega/Omega)*y(2) + y(2)/sqrt(1-y(2)^2)*(q/Omega)*cos(y(1)) + (epsilon/Omega)*cos(t*Omega);-sqrt(1-y(2)^2)*sin(y(1))+ kesi*((omega/Omega)*y(2) + y(2)/sqrt(1-y(2)^2)*(q/Omega)*cos(y(1)) + (epsilon/Omega)*cos(t.*Omega))];
it would seem ok, right?
Torsten
Torsten 2018 年 6 月 20 日
I can't tell since I don't know the differential equations you are trying to solve. All I can tell is that this system is different from the one you defined previously.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNumerical Integration and Differential Equations についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 6 月 20 日

コメント済み:

2018 年 6 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by