Diff does not work with symmatrix

6 vues (au cours des 30 derniers jours)
GIOSUÉ
GIOSUÉ le 14 Mar 2025
Commenté : GIOSUÉ le 14 Mar 2025
Consider the following very simple example:
syms a x [1,1] matrix
diff(x .^ (symmatrix(eye(1)) - a), x)
ans = 
The output of the function shoud be simply:
(symmatrix(eye(1)) - a)*x.^-a
while instead is returned exactly the same command of the input.
Is it a bug? Do you know any turn around?
Thank you
  1 commentaire
Torsten
Torsten le 14 Mar 2025
What is your real application ?

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 14 Mar 2025
Modifié(e) : Matt J le 14 Mar 2025
Element-wise exponentiation is not a standard matrix algebra operation. I imagine it is for that reason that symmatrix.diff() doesn't support it. Workaround:
syms a x [3,3]
F_vec = reshape(x .^ (eye(3) - a), [], 1);
dF_vec = jacobian(F_vec, x(:));
dF = reshape(diag(dF_vec), 3, 3)
dF = 
  1 commentaire
GIOSUÉ
GIOSUÉ le 14 Mar 2025
Thank you for your answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by