Error: The first argument must be a scalar.

49 ビュー (過去 30 日間)
Cantor Set
Cantor Set 2019 年 1 月 22 日
コメント済み: Cantor Set 2019 年 1 月 23 日
I defined a matrix of variables like this
X=sym('X', [4,1])
%it looks like this
X=[X1 X2 X3 X4]'
Then the code did some stuff on X to give a vector d of the form
d=[1-X1; 1-X2; 1-X3; 1]
Now I need to differentiat the ith element of d wrt the ith element of X, in other words I want to do this
I tried this
E=gradient(d, [X(1) X(2) X(3) X(4)]);
It gave me an error "The first argument must be a scalar"
So what should I do now?
Thanks!

採用された回答

Torsten
Torsten 2019 年 1 月 22 日
dd = [diff(d(1),X(1)),diff(d(2),X(2)),diff(d(3),X(3)),diff(d(4),X(4))]
  1 件のコメント
Cantor Set
Cantor Set 2019 年 1 月 23 日
Thanks :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by