Why matlab gives graph of exp(1/x) and exp(-1/x) wrong?
조회 수: 4 (최근 30일)
이전 댓글 표시
when trying to find graph of exp(1/x) and exp(-1/x) i am getting graphs that definitely not belong to exp(1/x) and exp(-1/x).
my codes are:
syms x
y=exp(-1/x) % or y=exp(1/x)
fplot(y)
when i run this, i get the graphs that as in below, figure 1 is belong to exp(-1/x) and figure 2 is belong to exp(1/x)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/620148/image.jpeg)
figure 1=exp(-1/x)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/620153/image.jpeg)
figure 2=exp(1/x)
But, this is absolutely ridiculous. The graphs of exp(1/x) and exp(-1/x) must be like :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/620158/image.png)
Is there anybody that will help me? I do not know where i am wrong, please if you know help me
thanks
댓글 수: 0
채택된 답변
Stephen23
2021년 5월 17일
편집: Stephen23
2021년 5월 17일
fun = @(x) exp(-1./x);
fplot(fun)
ylim([0,10])
fun = @(x) exp(1./x);
fplot(fun)
ylim([0,10])
I doubt there is much that can be done to change the automatic discontinuity detection algorithm, but feel free to read the documentation and see.
댓글 수: 5
Stephen23
2021년 5월 17일
"Now, how can we decide the limitations, to get a correct shape of curve?"
The shape is always "correct", as explained above. The only difference is how humans like to focus on particular parts or features of the curve: the computer does not know which parts you are interested in, only you know that. Possibly someone has published a heuristic algorithm to predict Y-limits for arbitrary functions.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!