Filter löschen
Filter löschen

Why won't my hold on work?

1 Ansicht (letzte 30 Tage)
Jay Gersten
Jay Gersten am 8 Nov. 2016
Bearbeitet: Walter Roberson am 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 Kommentare
Jay Gersten
Jay Gersten am 8 Nov. 2016
I'm using R2015a, on OS-X
Jay Gersten
Jay Gersten am 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....

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 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 Kommentar
Jay Gersten
Jay Gersten am 8 Nov. 2016
Bearbeitet: Walter Roberson am 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by