フィルターのクリア

trend line not drawing in sub-plot

1 回表示 (過去 30 日間)
nori
nori 2012 年 4 月 24 日
Hello,
I have this really strange issue going and it is really confusing me. I am trying to plot a trend line through a set of data and I can do it just fine in a regular plot, but as soon as I add it to a sub-plot, I can get either the data or the trend line and not both.
I did try to do it with the toolbox but in a subplot figure, I can only get 1 trend line to show up on any of my 5 subplots at a given time. so both methods are 'either or' and not both :(
any help would be greatly appreciated. thanx.
here is my code i am testing with.
a = [1 2 3 4 5]';
b = [3 7 9 3 7]';
figure
hold all
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
figure
subplot(2,1,1)
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 4 月 24 日
You need to hold on to your subplot!
figure
subplot(2,1,1)
hold on
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
  1 件のコメント
nori
nori 2012 年 4 月 24 日
jeez. i have been whacking at that problem for 2 hours!! i did try putting the 'hold' after the figure but i didnt try after the 'subplot'
thanks so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by