Diff does not work with symmatrix

조회 수: 6 (최근 30일)
GIOSUÉ
GIOSUÉ 2025년 3월 14일
댓글: GIOSUÉ 2025년 3월 14일
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
Torsten
Torsten 2025년 3월 14일
What is your real application ?

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

채택된 답변

Matt J
Matt J 2025년 3월 14일
편집: Matt J 2025년 3월 14일
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
GIOSUÉ
GIOSUÉ 2025년 3월 14일
Thank you for your answer.

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

추가 답변 (0개)

태그

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by