Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
定义不连续函数的任何简单方法(例如 f(x)=5 if x>5, f(x)=6x if x<5)并在区间内对其进行评估(例如 [0 6])。
这个怎么样:
f = @(x) 5*(x>5) + 6*x.*(x<5);
如在
t = 0:0.001:6; f = @(x) 5*(x>5) + 6*x.*(x<5); plot(t,f(t));
您可能希望更改定义以确保将 x = 5 时的情况定义为以下之一:
f = @(x) 5*(x>5) + 6*x.*(x<=5);
或者
f = @(x) 5*(x>=5) + 6*x.*(x<5);