Title the figure outputs of a function with different comments.
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!