Title the figure outputs of a function with different comments.

1 回表示 (過去 30 日間)
aneps
aneps 2014 年 5 月 1 日
編集済み: Star Strider 2014 年 5 月 1 日
I have a program which uses a function named 'PlotColorMap'(I created this function). This function plot color maps for the data. In this function starts with:
[ output_args ] = PlotColorMap( Data)
and ends in:
figure
h = pcolor(xb,yb,n1);
caxis auto
xlabel('X');ylabel('Y');
title('2D histogram X Y','fontweight','bold');
In my another code, I use this function several times. I want to title the figure each time with different comments. For example, if I am using this function in my code 3 times (let's say). Each time the figure should be titled "for the data in region 10 to 20" ,"for the data in region 30 to 40" and "for the data in region 60 to 80" respectively for the figures (3 figures separately titled so that I can identify them). I would be good if I can add with the last line along with "2D Histogram X Y" so that it appears "2D Histogram X Y for the data in region 10 to 20" like that....How can I do this?
Is it possible to give this along with the input variables, for example:
Modifying the function like
PlotColorMap(Data,add_title)
...
title('2D histogram X Y %f/d=add_title','fontweight','bold');
Something similar is possible?

採用された回答

Star Strider
Star Strider 2014 年 5 月 1 日
編集済み: Star Strider 2014 年 5 月 1 日
Use sprintf in your title call:
regionmtx = [10 20; 30 40; 60 80];
for k1 = 1:size(regionmtx,1)
figure(k1)
hist(k1+k1*randn(1, 100))
title(sprintf('2D histogram X Y For The Data In Region %d to %d', regionmtx(k1,:)), 'fontweight','bold')
axis([-5 15 0 25])
end

その他の回答 (0 件)

カテゴリ

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

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by