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 CenterFile Exchange에서 Title에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by