Matlab 2024a giving the wrong Jacobian

9 次查看(过去 30 天)
if I run the below code in MATLAB 2024a, jacobian is zero. However, this is wrong.
If I use "clear" instead of "clear all", the answer is correct. However, in 2023b in both cases (clear or clear all) I get the correct answer?
is this a bug? or what is the point?
clear all
clc
syms x y r
dy1 = x
dy2 = y
dr = r;
F=[dy1;dy2;dr]
% equilibrium_points = solve(F == 0, [x, y, r]);
% equilibrium_points = ...,
% [equilibrium_points.x, equilibrium_points.y, equilibrium_points.r];
J=jacobian(F,[x y r])

回答(1 个)

Aneela
Aneela 2024-6-5
Hi Gokhan,
I have tried this code in R2024a, it is working fine.
clear all
clc
syms a b c d m n s r x y k
dy1 = -x*( r*x.^2 - r*(a+b)*x + a*b +(c*y-r*d));
dy2 = s + m*x-n*y ;
dr = r-x;
F=[dy1;dy2;dr]
F = 
% equilibrium_points = solve(F == 0, [x, y, r]);
% equilibrium_points = ...,
% [equilibrium_points.x, equilibrium_points.y, equilibrium_points.r];
J=jacobian(F,[x y r])
J = 
“clear” – Removes variables from the workspace, but does not clear functions, global variables, or MEX files from the memory.
“clear all” – Removes all variables, functions, and MEX files from the memory, resetting MATLAB to a clean state.
Use the following command to know if there are multiple variables defined with same name at different locations:
which J -all
J is a variable.
  2 个评论
Gökhan
Gökhan 2024-6-6
which J -all
gives " J is a variable".
When I start the MATALB, at first run, (F5) the code gives the correct answer. At subsequent runs, it gives zero.
I tried it online, and always (subsequent) runs, it gives correct answer.
I think, it is something in my matlab in the computer.
Torsten
Torsten 2024-6-6
编辑:Torsten 2024-6-6
I remember a request a few days ago where a similar phenomenon occured together with the symbolic toolbox, and the same remedy (use of only "clear" instead of "clear all") was suggested by the support center. So it seems it is a known bug.
To be sure, contact TMW:

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by