I don't know why my code makes odeToVectorField error
2 ビュー (過去 30 日間)
古いコメントを表示
syms x(t)
m = 1;
k = 1;
F = 1;
fs = 1;
fk = 1;
[K,E] = ellipke((x / pi-floor(x/pi))*pi);
s = sqrt(2) * E + ( 2 * ellipke(1/2) * floor(x / pi));
r = abs(((cos(x))^2+1)^1.5/sin(x))
Ds = diff(s, t)
D2s = diff(s, t, 2)
dnjstlafur = 0.5 * (((m * Ds^2) / r) + abs(((m * Ds^2) / r - fs) - fs));
ode = m * D2s == sqrt(F^2 - dnjstlafur^2)
[V] = odeToVectorField(ode)
M = matlabFunction(V, 'vars', {'t', 'Y'});
a = 0;
b = 0;
[t, Y]= ode45(M,[0, 10],[a, b / sqrt((2 * k * a)^2 + 1)]);
When running this code, odeToVectorField error occurs... Can anyone help me to solve this problem?
1 件のコメント
Steven Lord
2023 年 9 月 19 日
Please show the full and exact text of the error message(s) you received when you ran that code (all the text displayed in red in the Command Window).
採用された回答
Torsten
2023 年 9 月 19 日
編集済み: Torsten
2023 年 9 月 19 日
From the documentation:
odeToVectorField can convert only quasi-linear differential equations. That is, the highest-order derivatives must appear linearly. For example, odeToVectorField can convert y*y″(t) = –t^2 because it can be rewritten as y″(t) = –t^2/y. However, it cannot convert y″(t)^2 = –t^2 or sin(y″(t)) = –t^2.
0 件のコメント
その他の回答 (1 件)
Sam Chak
2023 年 9 月 19 日
編集済み: Sam Chak
2023 年 9 月 19 日
The highest-order derivative
is embedded in
or D2s. Notably, one of the terms in this context is nonlinear, as demonstrated by
below.
below. To successfully utilize the 'odeToVectorField()' function, it's essential for the highest-order derivatives to appear linearly. To address this, I recommend attempting to solve this implicit differential equation using the 'ode15i()' command. See also decic().
syms x(t)
m = 1;
k = 1;
F = 1;
fs = 1;
fk = 1;
[K, E] = ellipke((x/pi - floor(x/pi))*pi);
% Test
% s = x; % this one should work!
s = sqrt(2)*E + 2*ellipke(1/2)*floor(x/pi)
r = abs(((cos(x))^2 + 1)^1.5/sin(x)); % singularity occurs at x(t) = 0
Ds = diff(s, t); % time derivative of a unknown function s
D2s = diff(s, t, 2); % double-dot x is inside here
dnjstlafur = 0.5*((m*Ds^2)/r + abs((m*Ds^2)/r - 2*fs));
eqn = m*D2s == sqrt(F^2 - dnjstlafur^2)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





