MuPAD w. MATLAB 2015a: How to (properly) plot x*exp(-x/1.e-8) ?

I tried the following plot command in MuPAD running in MATLAB 2015a:
plot(x*exp(-x/1.e-8), x=0..5e-8)
and also tried:
plot(x*exp(-x/1.e-8), ViewingBox=[0..5e-8, 0..5e-9])
The result in both cases is a vertical axis from -1 to 1 and a graph that traces y=0. These commands properly displayed the graph in the MATLAB 2013a version of MuPAD (the maximum value of the function is approx. 3.7e-9 occurring at x approx. 1.e-8. Another thing I discovered was that if I use 1.e-7 in the function instead of 1.e-8, the 2015a version works fine. How can it properly plot it using 1.e-8 (or smaller) using the 2015a version of MuPAD?

4 Comments

I wonder if it would make a difference if you increased Digits ?
Thanks for the good suggestion, Walter!
I just tried it, and it doesn't correct the plotting problem.
Specifically, I tried:
DIGITS:=50
I also tested the numerical accuracy of a relevant calculation:
x*exp(-x/1.e-8) |x=1.e-8
and got the correct answer (to 50 significant figures):
0.0000000036787944117144232159552377016146086744581113103177
If it's a computational-accuracy error, it would seem to be happening within the plot command. Still puzzled ...
Out of curiosity, how about if you switch it to an explicit multiply inside of divide by a fraction?
plot(x*exp(-x*1.e8), x=0..5e-8)
Just tried your suggestion:
plot(x*exp(-x*1.e8), x=0..5e-8)
Same basic problem. The plot traces y=0 using a vertical range of -1 to 1, but if I use 1.e7, as in the following, that function gets properly displayed using a vertical range of 0 to 4e-8
plot(x*exp(-x*1.e7),x=0..5e-7)

Sign in to comment.

Answers (0)

Asked:

on 8 Oct 2015

Commented:

on 9 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!