フィルターのクリア

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 Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by