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!