Invalid Handle Object with Subplot
古いコメントを表示
Hi, I would appreciate any help on this matter, thank you for reading :)
I am attempting to do something like the following:
x1 = [1 2 3 4];
y1 = [2 4 6 8];
y2 = [4 8 12 16];
figure; hold on;
h1 = subplot(1,2,1);
hold on;
plot(x1,y1)
h2 = subplot(1,2,2);
hold on;
plot(x1,y2);
set(h1,'title','test1');
set(h2,'title','test2');
However, I get the error:
??? Error using ==> set Value must be a handle
I have also attempted to set both the figure and subplot properties to include 'NextPlot','add' but this did not help.
Thanks for all suggestions!
採用された回答
その他の回答 (1 件)
the cyclist
2011 年 10 月 28 日
Are you just trying to set titles of each subplot?
x1 = [1 2 3 4];
y1 = [2 4 6 8];
y2 = [4 8 12 16];
figure; hold on;
h1 = subplot(1,2,1);
title('test1')
hold on;
plot(x1,y1)
h2 = subplot(1,2,2);
title('test2')
hold on;
plot(x1,y2);
Part of the problem of the way you were trying to do it was that h1 and h2 are the handles for the lines plotted, not for the plotting axes.
2 件のコメント
Erin MacMillan
2011 年 10 月 28 日
Daniel Shub
2011 年 10 月 28 日
The handles h1 and h2 are handles to the axes since they are returned by subplot. The problem is that the title property does not want a string, but rather a handle.
カテゴリ
ヘルプ センター および File Exchange で Axis Labels についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!