Undefined function 'piecewise' for input arguments of type 'double'. or 'Conversion to logical from sym is not possible.' errors
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function deflectionV=Deflection_ptbui3(deflPos)
syms deflPos
deflectionV=piecewise((0<deflPos)&&(deflPos<=120),800*(deflPos)^3-13.68*10^6*(deflPos)-2.5*(deflPos)^4,(120<deflPos)&&(deflPos<=240),800*(deflPos)^3-13.68*10^6*(deflPos)-2.5*(deflPos)^4+(2.5*(deflPos-120)^4),(240<deflPos)&&(deflPos<=360),800*(deflPos)^3-13.68*10^6*(deflPos)-2.5*(deflPos)^4+(2.5*(deflPos-120)^4)+(600*(deflPos-240)^3));
deflectionV=(1/3.19E9)*deflectionV;
end
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. :)
0 Kommentare
Antworten (1)
Ajay Pattassery
am 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.
deflectionV=piecewise((0<deflPos)&(deflPos<=120),800*(deflPos)^3-13.68*10^6*(deflPos)-2.5*(deflPos)^4,(120<deflPos)&(deflPos<=240),800*(deflPos)^3-13.68*10^6*(deflPos)-2.5*(deflPos)^4+(2.5*(deflPos-120)^4),(240<deflPos)&(deflPos<=360),800*(deflPos)^3-13.68*10^6*(deflPos)-2.5*(deflPos)^4+(2.5*(deflPos-120)^4)+(600*(deflPos-240)^3));
0 Kommentare
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!