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!





