Live script error - Error in state of SceneNode
38 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ron
il 7 Dic 2024 alle 14:55
Commentato: Ron
il 8 Dic 2024 alle 4:05
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 Commenti
Walter Roberson
il 7 Dic 2024 alle 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.
Risposta accettata
Anjaneyulu Bairi
il 7 Dic 2024 alle 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!
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!