Effacer les filtres
Effacer les filtres

Why won't my hold on work?

2 vues (au cours des 30 derniers jours)
Jay Gersten
Jay Gersten le 8 Nov 2016
I am trying to plot a piece wise function using fplot. The code won't retain the previous graphs. I tried even using the example code that is online with mathwork and even that doesn't work! it only plots the second equation! What is going with matlab!?
This is my code
clc; clf;
fplot(@(x) ((-1/4)*x^2 + 11.8125),[0 6],'r')
hold on
fplot(@(x) ((-1/4)*x^2 + 11.8125 + .5*(x-6)^2),[6 12],'r')
hold off
grid on
This is the code from mathwork that I pretty much copied. Same idea, I just needed different equations. Neither work!I think something is wrong with my hold on.
fplot(@(x) exp(x),[-3 0],'b')
hold on
fplot(@(x) cos(x),[0 3],'b')
hold off
grid on
  3 commentaires
Jay Gersten
Jay Gersten le 8 Nov 2016
I'm using R2015a, on OS-X
Jay Gersten
Jay Gersten le 8 Nov 2016
I tried hold on in a different setting and it worked fine. Perhaps this doesn't work in the older version? Does that make sense? This seems like a basic function that should have been able to be done in earlier versions....

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 8 Nov 2016
The problem is not hold on, the problem is fplot, which in R2015a made no attempt to check to see if it was on a held axes. R2016a is the first version of fplot that respects hold on
  1 commentaire
Jay Gersten
Jay Gersten le 8 Nov 2016
Modifié(e) : Walter Roberson le 8 Nov 2016
Thank you. They should definitely specify that it only works in the latest edition. That was much wasted time and effort. Appreciate the tip.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by