Replacing function variables with a vector before taking a gradient

3 ビュー (過去 30 日間)
Valeri Aronov
Valeri Aronov 2021 年 7 月 30 日
回答済み: Walter Roberson 2021 年 7 月 31 日
I have a symbolic function:
A = 1/((C1*C2*R1*R2*w^2 - 1)^2 + w^2*(C2*R1 + C2*R2)^2)^(1/2)
I would like to replace C1, C2, R1, R2 symbolic variables with an x vector where C1 = C1_0*x(1); C2 = C2_0*x(2); R1 = R1_0*x(3); R2 = R2_0*x(4); and take a gradient of A by x. Whatever I tried failed to produce the result I am seeking.
  3 件のコメント
Valeri Aronov
Valeri Aronov 2021 年 7 月 30 日
I do it symbolically, if I got your question right.
Valeri Aronov
Valeri Aronov 2021 年 7 月 31 日
編集済み: Valeri Aronov 2021 年 7 月 31 日
I have found a path (I did not know about str2sym() existence):
syms x1 x2 x3 x4 real
x=[x1,x2,x3,x4]
A = subs(A, C1, str2sym('x1*C1_0'))
A = subs(A, C2, str2sym('x2*C2_0'))
...
gradient(A, x)
It may do for me even ideally I would prefer the notation in my question text for x.
Now, can some one advise if I need to remove this question entirely.

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 7 月 31 日
syms x1 x2 x3 x4 real
syms C1_0 C2_0
x=[x1,x2,x3,x4]
A = subs(A, [C1, C2, R1, R2], [C1_0, C2_0, R1_0, R2_0] .*x)
gradient(A, x)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by