Problem related with "odeToVectorField"
9 ビュー (過去 30 日間)
古いコメントを表示
I used this code to create symbolic equation.
a_sym = sym('a', [N, 1], 'real');
a_dot_sym = sym('a_dot', [N, 1], 'real');
dJ_da_sym = sym('dJ_da', [N, 1], 'real');
for j = 1:N
a_dot_sym(j) = dJ_da_sym(j)*(dJ_da_sym(j) - lambda);
end
I got these equations 3 equation in ode.
-(100000*(4*a1 + 1/25)*(a1 - 99/100)^2 - 292000*a1*(a1 - 1)^2 + 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 800*a2*((53*a1)/500 - 499947/50000)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 + 1200*a3*((53*a2*((53*a1)/5000 - 499947/500000))/500 + 10)^3*(a3 - 1)^2)*(292000*a1*(a1 - 1)^2 - 100000*(4*a1 + 1/25)*(a1 - 99/100)^2 - 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 + 800*a2*((53*a1)/500 - 499947/50000)^3*(a2 - 1)^2 + 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 - 1200*a3*((53*a2*((53*a1)/5000 - 499947/500000))/500 + 10)^3*(a3 - 1)^2 + 1/100)
(108000*a1*(a1 - 1)^2 - 100*(8*a2 + 2/25)*((53*a1)/500 - 10)^3*(a2 - 99/100)^2 + 1200*a3*(a3 - 1)^2*((53*(2*a2 + 1/50)*((53*a1)/5000 - 1))/1000 + 10)^3 + 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2)*(108000*a1*(a1 - 1)^2 - 100*(8*a2 + 2/25)*((53*a1)/500 - 10)^3*(a2 - 99/100)^2 + 1200*a3*(a3 - 1)^2*((53*(2*a2 + 1/50)*((53*a1)/5000 - 1))/1000 + 10)^3 + 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 - 1/100)
-(108000*a1*(a1 - 1)^2 + 100*(12*a3 + 3/25)*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 99/100)^2 - 508*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2)*(508*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 100*(12*a3 + 3/25)*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 99/100)^2 - 108000*a1*(a1 - 1)^2 + 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 + 1/100)
Now I want to use the function "odeToVectorField".
F = odeToVectorField(a_dot_sym);
But I received the error.
Error using mupadengine/feval_internal
Unable to find the differential variables. Try specifying the dependent ODE variables using symbolic functions instead, such as 'syms
f(x)'.
Error in odeToVectorField>mupadOdeToVectorField (line 171)
T = feval_internal(symengine,'symobj::odeToVectorField',sys,x,stringInput);
Error in odeToVectorField (line 119)
sol = mupadOdeToVectorField(varargin);
Error in SED2 (line 82)
F = odeToVectorField(a_dot_sym);
What is the solution of this problem? Please help. Thanks in advance.
0 件のコメント
回答 (1 件)
Sam Chak
2023 年 9 月 2 日
I don't see any symbolic differential variables in these three so-called ODEs. That's why odeToVectorField() threw the error message. Can you rewrite the ODEs in terms of differential variables?
% -(100000*(4*a1 + 1/25)*(a1 - 99/100)^2 - 292000*a1*(a1 - 1)^2 + 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 800*a2*((53*a1)/500 - 499947/50000)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 + 1200*a3*((53*a2*((53*a1)/5000 - 499947/500000))/500 + 10)^3*(a3 - 1)^2)*(292000*a1*(a1 - 1)^2 - 100000*(4*a1 + 1/25)*(a1 - 99/100)^2 - 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 + 800*a2*((53*a1)/500 - 499947/50000)^3*(a2 - 1)^2 + 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 - 1200*a3*((53*a2*((53*a1)/5000 - 499947/500000))/500 + 10)^3*(a3 - 1)^2 + 1/100)
% (108000*a1*(a1 - 1)^2 - 100*(8*a2 + 2/25)*((53*a1)/500 - 10)^3*(a2 - 99/100)^2 + 1200*a3*(a3 - 1)^2*((53*(2*a2 + 1/50)*((53*a1)/5000 - 1))/1000 + 10)^3 + 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2)*(108000*a1*(a1 - 1)^2 - 100*(8*a2 + 2/25)*((53*a1)/500 - 10)^3*(a2 - 99/100)^2 + 1200*a3*(a3 - 1)^2*((53*(2*a2 + 1/50)*((53*a1)/5000 - 1))/1000 + 10)^3 + 292*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 - 1/100)
% -(108000*a1*(a1 - 1)^2 + 100*(12*a3 + 3/25)*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 99/100)^2 - 508*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2)*(508*a2*((53*a1)/500 - 10)^3*(a2 - 1)^2 - 100*(12*a3 + 3/25)*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 99/100)^2 - 108000*a1*(a1 - 1)^2 + 292*a3*((53*a2*((53*a1)/5000 - 1))/500 + 10)^3*(a3 - 1)^2 + 1/100)
A symbolic differential variable looks like this:
syms x(t)
x(t) = sin(t);
Dx = diff(x,t)
You can also find some examples in this documentation:
2 件のコメント
Sam Chak
2023 年 9 月 3 日
Hi @Sol Elec
I couldn't find any symbolic differential variables in your entire code. Please try searching for the keyword 'diff('. I suggest that you directly display the three mathematical differential equations so that we can compare them with your code to ascertain the correctness of the ODEs in your code.
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!