Live script error - Error in state of SceneNode
79 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ron
el 7 de Dic. de 2024
Comentada: Ron
el 8 de Dic. de 2024
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 comentarios
Walter Roberson
el 7 de Dic. de 2024
"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.
Respuesta aceptada
Anjaneyulu Bairi
el 7 de Dic. de 2024
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!
Más respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
