fplot fails to produce a graph

The first fplot in the following code doesn't produce a graph (only a coordinate system) while the second fplot does. Why? (MATLAB R2016a; Windows 7 Enterprise)
r = 50; L = 110; h = 40;
th = @(t) 80*(t+exp(-t)-1);
y = @(t) r*sin(th(t)) + sqrt(L^2-(r*cos(th(t))).^2) + h;
f = @(t) y(t) - 195;
fplot(y,[0 2])
figure
fplot(f,[0 2])

9 commentaires

Star Strider
Star Strider le 22 Sep 2016
I cannot reproduce the error. I get the same plot for both, offset by -195 in the second (in R2016b, Win 8.1).
Henning Søgaard
Henning Søgaard le 22 Sep 2016
The problem does not occur in R2015b either, so I assume that it may be a R2016a issue only.
Star Strider
Star Strider le 22 Sep 2016
See if you get the same result with the ezplot function.
Walter Roberson
Walter Roberson le 22 Sep 2016
I confirm the behaviour in R2016a on OS-X
There does not appear to be any public bug report about this.
Henning Søgaard
Henning Søgaard le 23 Sep 2016
Modifié(e) : Henning Søgaard le 23 Sep 2016
Replacing fplot by ezplot solves the problem in R2016a, so it seems to be a fplot issue solely.
Adam
Adam le 23 Sep 2016
I also got the same behaviour on Windows 10 in Matlab 2016a
Kevin Goheen
Kevin Goheen le 23 Oct 2016
The 400+ students in our introduction to numerical computing class are often getting similar errors, and it often leads to subsequent commands such as fzero not working. This did not occur in R2015a. When I reported this, Matlab technical support said that R2016b had the same wrong behaviour.
Walter Roberson
Walter Roberson le 23 Oct 2016
I just tested in R2016b on OS-X, and in R2016b on Windows 10, and the fplot does work now.
Karan Gill
Karan Gill le 25 Oct 2016
A public bug report exists: http://www.mathworks.com/support/bugreports/1383817. As a workaround, it states: "You might be able to work around this behavior by tweaking the x-axis range. For example, try fplot(@f,[2 3.1]) instead of fplot(@f,[2 3]). Otherwise, set the axis range using the axis function, for example, axis([0 2 -5 5]) (i.e., [xmin xmax ymin ymax])."

Connectez-vous pour commenter.

Réponses (1)

Mudambi Srivatsa
Mudambi Srivatsa le 26 Sep 2016

0 votes

This is a bug in MATLAB R2016a and it is resolved in MATLAB R2016b. You can upgrade to R2016b to resolve the issue or use "ezplot" as a workaround in R2016a.

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by