# usage of ode45

13 ビュー (過去 30 日間)
Hicham 2024 年 4 月 12 日
コメント済み: Star Strider 2024 年 4 月 14 日
i have 3 differential eqns that i would like to solve using ode45. M, l1, V are all varying w.r.t. time evrything else are just constants

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

### 回答 (1 件)

Star Strider 2024 年 4 月 12 日
syms M(t) I_1(t) I_2 V(t) t g mu A Y T
Eq1 = diff(M) == -g*V*A
Eq1(t) =
Eq2 = diff(V) == I_1*g/(I_1+I_2) - 8*pi*mu*V/(g*A)
Eq2(t) =
Eq3 = diff(I_1) == -V
Eq3(t) =
[VF,Subs] = odeToVectorField(Eq1, Eq2, Eq3)
VF =
Subs =
fcn = matlabFunction(VF, 'Vars',{T,Y,g,I_2,mu,A})
fcn = function_handle with value:
@(T,Y,g,I_2,mu,A)[(g.*Y(3))./(I_2+Y(3))-(mu.*pi.*Y(1).*8.0)./(A.*g);-A.*g.*Y(1);-Y(1)]
g = rand
g = 0.3866
I2 = rand
I2 = 0.7057
mu = rand
mu = 0.0208
A = rand
A = 0.1406
[t,y] = ode45(@(t,y)fcn(t,y,g,I2,mu,A), [0,100], rand(3,1));
figure
plot(t, y)
grid
xlabel('Time')
ylabel('Amplitude')
legend(string(Subs), 'Location','best')
Make appropriate corrections to the symbolic variables (I am not certain that I transcribed them correctly), supply values for the constants parameters, and then use ode45 (or ode15s if the parameters vary significantly in magnitude) to solve it numerically.
.
##### 2 件のコメントなしを表示なしを非表示
Hicham 2024 年 4 月 13 日
what was the function matlabFunction that u used. and how can i program it without the usage of the first ode dm/dt
Star Strider 2024 年 4 月 14 日
The matlabFunction function is part of the Symbolic Math Toolbox.
If you do not want to include the first differential equation, do not include it in the odeToVectorField arguments, using:
[VF,Subs] = odeToVectorField(Eq2, Eq3)
.

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

### カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by