Undefined function 'piecewise' for input arguments of type 'double'. or 'Conversion to logical from sym is not possible.' errors

3 views (last 30 days)
Phuquy Bui
Phuquy Bui on 13 Feb 2020
Answered: Ajay Pattassery on 18 Feb 2020
function deflectionV=Deflection_ptbui3(deflPos)
syms deflPos
This is my code for the function for my piecewise, but whenever I call for it in my actual script, I get a 'Conversion to logical from sym is not possible.' error.
I've been trying to do this problem where i put the user input into a piecewise function.
Before when I didn't have the syms, it would also just give me 'Undefined function 'piecewise' for input arguments of type 'double'. So i'm not entirely sure whats going on and my teacher nor TA's know very much about the function. And if you think it isn't gonna work, please let me know so I can get the closure to delete this mess of a function. :)

Answers (1)

Ajay Pattassery
Ajay Pattassery on 18 Feb 2020
The logical operator && is a short-circuit operator which means the second operand is only evaluated when the result is not fully determined by the first operand. Refer here for more information.
In your case logical and (&) need to be used.


Community Treasure Hunt

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

Start Hunting!