Matlab 2024a giving the wrong Jacobian

4 views (last 30 days)
Gökhan
Gökhan on 5 Jun 2024
Edited: Torsten on 6 Jun 2024
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])

Answers (1)

Aneela
Aneela on 5 Jun 2024
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 Comments
Gökhan
Gökhan on 6 Jun 2024
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 on 6 Jun 2024
Edited: Torsten on 6 Jun 2024
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:

Sign in to comment.

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!