Gradient of vector-valued function

Code below throws an error. How is it possible to get the gradient for a vector-valued function?
syms a b1 b2 t
mfcn = matlabFunction(b1.*t^2+b2.*t, 'Vars', {[b1,b2],t})
gradient(mfcn,t)

回答 (2 件)

Moritz Schulze
Moritz Schulze 2017 年 10 月 24 日

0 投票

syms a b1 b2 t
mfcn = matlabFunction(b1.*t^2+b2.*t)
gradient(mfcn,t)
This works on the contrary.
VBBV
VBBV 2022 年 12 月 17 日

0 投票

use diff instead of gradient which is equivalent for gradient operation for symbolic expressions
syms a b1 b2 t
mfcn = matlabFunction(b1.*t.^2+b2.*t,'Vars', {b1,b2,t})
mfcn = function_handle with value:
@(b1,b2,t)b2.*t+b1.*t.^2
diff(mfcn,t) % use diff instead of gradient
ans = 

質問済み:

2017 年 10 月 24 日

回答済み:

2022 年 12 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by