Title the figure outputs of a function with different comments.

2 views (last 30 days)
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?

Accepted Answer

Star Strider
Star Strider on 1 May 2014
Edited: Star Strider on 1 May 2014
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

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!