I don't know why my code makes odeToVectorField error

2 ビュー (過去 30 日間)
Student
Student 2023 年 9 月 19 日
編集済み: Sam Chak 2023 年 9 月 19 日
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))
r(t) = 
Ds = diff(s, t)
Ds(t) = 
D2s = diff(s, t, 2)
D2s(t) = 
dnjstlafur = 0.5 * (((m * Ds^2) / r) + abs(((m * Ds^2) / r - fs) - fs));
ode = m * D2s == sqrt(F^2 - dnjstlafur^2)
ode(t) = 
[V] = odeToVectorField(ode)
Error using symengine
Invalid argument.

Error in mupadengine/evalin_internal

Error in mupadengine/fevalHelper

Error in mupadengine/feval_internal

Error in odeToVectorField>mupadOdeToVectorField (line 171)
T = feval_internal(symengine,'symobj::odeToVectorField',sys,x,stringInput);

Error in odeToVectorField (line 119)
sol = mupadOdeToVectorField(varargin);
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
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
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.

その他の回答 (1 件)

Sam Chak
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.
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)
s(t) = 
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)
eqn(t) = 

カテゴリ

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