绘制分段符号函数

时间:2016-05-02 18:36:52

标签: matlab plot symbolic-math

所以,这是我的剧本:

syms t r w
x1=5^-t*heaviside(t);
x_2=subs(x1,t,t-r);
x2=conj(x_2);
R=int(x1*x2,t,-inf,inf);
R=simplify(R)

ezplot(R, [-10 10]);

R=piecewise([0 <= r, 1/5^r/(2*log(5))], [r <= 0, 5^r/(2*log(5))])

正如您所看到的,我正在尝试使用ezplot函数绘制符号解决方案但我收到此错误:

The input string must be an expression.  Implicit functions of a single variable are not supported.

据我所知,matlab不适用于分段函数。有没有其他方法可以绘制这个函数?

1 个答案:

答案 0 :(得分:2)

我采用了用ineqalities重写分段表达式的方法:

ezplot(@(r)(0 <= r)*1/5^r/(2*log(5)) + (r <= 0)*5^r/(2*log(5)));

复制粘贴并不理想,但它总比没有好。

或者你可以用数字来评估这个:

x = -10:0.01:10;
y = eval(subs(R,r,x));
plot(x,y)