need solution with symbolic

3 ビュー (過去 30 日間)
Ali Najem
Ali Najem 2020 年 10 月 8 日
コメント済み: Ameer Hamza 2020 年 10 月 8 日
Dear all
why the first code is working otherwise in second code when I just change a bit it won't work ?
The first code
syms z2
Z2(z2) = piecewise(0<=z2, z2, 0>z2, 0.2*(exp(z2)-1));
Z2([10])
The second code
syms w12 a1 b12 z2
z2 = w12*a1 + b12;
Z2(z2)=piecewise(0<=z2, z2, 0>z2, 0.2*(exp(z2)-1));
Z2([10])
Any suggestion please?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
Here:
Z2(z2)=piecewise(0<=z2, z2, 0>z2, 0.2*(exp(z2)-1));
%^
z2 is not an independent symbolic variable. It is a symbolic expression. You should use the base variables to make symbolic functions. For example
syms w12 a1 b12 z2
z2 = w12*a1 + b12;
Z2(w12,a1,b12)=piecewise(0<=z2, z2, 0>z2, 0.2*(exp(z2)-1));
Z2(10, 1, 2)
  2 件のコメント
Ali Najem
Ali Najem 2020 年 10 月 8 日
編集済み: Ali Najem 2020 年 10 月 8 日
it worked thanks alot sir
Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by