Live script error - Error in state of SceneNode
38 ビュー (過去 30 日間)
古いコメントを表示
I'm evaluating Symbolic Math Toolbox, but can't get the following to run without error:
syms u(t)
[V] = odeToVectorField(diff(u,2) == u -(1/5)*u^3 + cos(t)
M = matlabFunction(V, 'Vars', {'t', 'Y'})
sol = ode45(M, [0 20],[0 0])
fplot(@(t)deval(sol,t,1), [0, 20])
xlabel("time")
ylabel("solution")
Plot gives 'Warning: Error in state of SceneNode
The following error was reported evaluating the function in Functiion
- Not sure how to deal with this snce running the same code in a different live script works OK, unless I increase the plotting interval beyond 20
- I'm new to this add on and would be grateful for any help in understanding the syntax used by toolbox
Many thanks for you help.
2 件のコメント
Walter Roberson
2024 年 12 月 7 日 22:19
"Error in state of SceneNode" usually occurs when a text or label or title or tick label Interpreter is set to LaTex, but the corresponding string is not valid LaTex code (as far as the basic latex interpretation goes.)
An example of the error is
txt = sprintf('$T=%.1f%c$C', T(i), char(176));
text(Nodes(i,1), Nodes(i, 2), txt , 'Interpreter','latex');
This uses a character position beyond 127, but LaTex intepreter can only process characters up to code position 127.
採用された回答
Anjaneyulu Bairi
2024 年 12 月 7 日 16:36
Hi,
When I attempted to run the code you provided, it did not initially display any errors as you mentioned. However, I encountered a syntax error related to "odeToVectorField." After adjusting the syntax, the code executed without any issues.
I recommend uninstalling the add-on and then reinstalling it. If the error persists, consider using alternative solvers such as "ode15s" or "ode23".
Here is the output of the code execution:
syms u(t)
[V] = odeToVectorField(diff(u,2) == u -(1/5)*u^3 + cos(t)) % Modified line to remove syntax error.
% number of parentheses were not matching
M = matlabFunction(V, 'Vars', {'t', 'Y'})
sol = ode45(M, [0 20],[0 0])
fplot(@(t)deval(sol,t,1), [0, 20])
xlabel("time")
ylabel("solution")
Hope it helps!
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!