Create a function based on some criteria

2 次查看(过去 30 天)
Suppose I want to create a function :
y=x^2 for x>5
x^3 for 0<x<=5
-1 for x<0
How to implement this in matlab without using fucntion?
Can it be done in single statement so that I can plot this or use in other functions?

采纳的回答

KSSV
KSSV 2021-9-17
编辑:KSSV 2021-9-17
if x <= 0
y = -1 ;
elseif x > 0 && x <= 5
y = x^3 ;
elseif x > 5
y = x^2 ;
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by