Take the derivative of a SYMBOLIC Matrix with respect to a Vector
Mostra commenti meno recenti
Hi community,
I am trying to compute the derivative of a matrix
with respect to a vector
. Both have symbolic components. I cannot use the naive 'for-loop' implementation because the matrix is quite large and, more importantly, the
and in general is quite complex (many trigonometric functions). I was wondering if there is a faster 'vectorized' implementation to perform this computation.
and in general is quite complex (many trigonometric functions). I was wondering if there is a faster 'vectorized' implementation to perform this computation.% PSEUDOCODE of WHAT I HAVE
% M = matrix function of (x) size: [nxn]
% x vector size: [nx1]
n = length(x)
for i = 1:n
for j = 1:n
for k = 1:n
M_ij = M(i,j)
dM_dx(i,j,k) = diff(M_ij, x(k))
end
end
end
I would like to know if there is a method to perform this computation without for loops, like the following:
% PSEUDOCODE of WHAT I WISH
dM_dx = diff(M, x)
PS: I already tried to look at: Differentiate symbolic expression or function - MATLAB diff (mathworks.com) but doesn't seem to work since it gives me the following error:
'Components of second argument explicitly present in first argument.'
Thank you very much for the help!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Assumptions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!