how to stem an expression function in discrete manner as using fplot to evaluate expression function in continuous manner?
9 次查看(过去 30 天)
显示 更早的评论
I can use fplot to plot an expression, which means I can plot the function without specify the range of dependent variable. For example, >>syms x; fplot(heaviside(x),[-4, 4]); It plots the continous function heaviside and show plots from range [-4 4]. Now, supposedly I want an discrete sample of such plot how do I do it ?
For example, I tried: >>syms x; stem(heaviside(x),[-4,4]); ==> but matlab cannot using stem function to evaluate the expression function.
I know that I can do: >> x=-10:10; stem(heaviside(x),[-4,4]); ==> matlab will plot this, but it is not what I want, I want it to be ploted in the discrete manner without specifying "x=-10:10". In other words, I want an function expression to be evaluated in the way that stem function does to an definite function. Or to say if there is a discrete plot/stem function for an expression function like fplot for continuous expression function?
Thank you very much!
0 个评论
回答(1 个)
Walter Roberson
2017-3-17
编辑:Walter Roberson
2017-3-17
You can pass a function handle to fplot. You can use matlabFunction to create function handles from symbolic expressions.
However, not all symbolic expressions can be converted. If the expression makes use of a symbolic function that there is no corresponding numeric function for, such as piecewise, then it might not be able to do the conversion.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!