if a > 10^-8 switch1 = b; else switch1 = 0; end
i get the following error:
Conversion to logical from sym is not possible.
if a > 10^-8
I Need the above code to work with symbolic variables.
You need to use piecewise() for this purpose.
According to your comments, 'a' is a symbol symbolizing a scalar number. If that's the case, you can convert 'a' to numerical.
a = sym('3.14159'); a = double(a); % Convert to double if a > 10^-8 ... else ... end
If you prefer to keep 'a' in the sym class, use Walter's answer.