Live script error - Error in state of SceneNode

조회 수: 62 (최근 30일)
Ron
Ron 2024년 12월 7일
댓글: Ron 2024년 12월 8일
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
Walter Roberson 2024년 12월 7일
"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.
Ron
Ron 2024년 12월 8일
I don't see anything in the code that is text beyond ascii 127. I wonder if it has something to do with the fact that my matlab is R204b, and Symbolic Math Toolbox 24.2. Anyway thanks for replying.

댓글을 달려면 로그인하십시오.

채택된 답변

Anjaneyulu Bairi
Anjaneyulu Bairi 2024년 12월 7일
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'})
M = function_handle with value:
@(t,Y)[Y(2);cos(t)-Y(1).^3./5.0+Y(1)]
sol = ode45(M, [0 20],[0 0])
sol = struct with fields:
solver: 'ode45' extdata: [1x1 struct] x: [0 2.0095e-04 0.0012 0.0062 0.0313 0.1569 0.7508 1.5690 2.5427 3.0128 3.4829 3.9216 4.4227 5.1243 6.0899 6.7273 7.2162 7.7051 8.1551 8.7221 9.5564 ... ] (1x46 double) y: [2x46 double] stats: [1x1 struct] idata: [1x1 struct]
fplot(@(t)deval(sol,t,1), [0, 20])
xlabel("time")
ylabel("solution")
Hope it helps!
  댓글 수: 1
Ron
Ron 2024년 12월 8일
I simply re-typed the [V] line and now all is well. Must have been some hidden character (like Alt255) embedd. Anyway, thanks for your help, it runs OK now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by