need solution with symbolic

5 views (last 30 days)
Ali Najem
Ali Najem on 8 Oct 2020
Commented: Ameer Hamza on 8 Oct 2020
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?

Accepted Answer

Ameer Hamza
Ameer Hamza on 8 Oct 2020
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 Comments
Ali Najem
Ali Najem on 8 Oct 2020
Edited: Ali Najem on 8 Oct 2020
it worked thanks alot sir
Ameer Hamza
Ameer Hamza on 8 Oct 2020
I am glad to be of help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!