필터 지우기
필터 지우기

Why won't my hold on work?

조회 수: 2 (최근 30일)
Jay Gersten
Jay Gersten 2016년 11월 8일
편집: Walter Roberson 2016년 11월 8일
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
Jay Gersten
Jay Gersten 2016년 11월 8일
I'm using R2015a, on OS-X
Jay Gersten
Jay Gersten 2016년 11월 8일
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....

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 11월 8일
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
Jay Gersten
Jay Gersten 2016년 11월 8일
편집: Walter Roberson 2016년 11월 8일
Thank you. They should definitely specify that it only works in the latest edition. That was much wasted time and effort. Appreciate the tip.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by