The title of a figure

Hye, How could I give a title to a figure that depend on the input of the function that create the figure.

 채택된 답변

Jan
Jan 2011년 7월 19일

10 개 추천

At creation:
figure('NumberTitle', 'off', 'Name', 'This is the figure title');
After creation:
FigH = figure;
...
set(FigH, 'NumberTitle', 'off', ...
'Name', sprintf('Date: %s', datestr(now, 0)));
[EDITED]: 'NumerTitle' -> 'NumberTitle'

댓글 수: 5

Liber-T
Liber-T 2011년 7월 19일
I made a test
figure('NumerTitle', 'off', 'Name', 'heyhey')
subplot(2,1,1)
plot(beta,s,'k')
...
and I received this:
??? Error using ==> figure
Invalid figure property: 'NumerTitle'.
Error in ==> wplasmainhr at 29
figure('NumerTitle', 'off', 'Name', 'heyhey')
Daniel Shub
Daniel Shub 2011년 7월 19일
I am sure Jan will catch this, but it is NumberTitle not NumerTitle. He will probaly start ranting about the preview latency.
Jan
Jan 2011년 7월 19일
*Ranting*?! I'm *crying*. Currently I have to wait for 2 seconds after each keystroke. Irch #+*7&
Jan
Jan 2011년 7월 19일
*Ranting*?! I'm *crying*. Currently I have to wait for 2 seconds after each keystroke. Irch #+*7&
@Liber-T: There might be a misunderstanding: What exactly do you mean by "title"? The title on top of the plots inside the figure, or the title of the Window?
Liber-T
Liber-T 2011년 7월 19일
Thanks to both of you.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Daniel Shub
Daniel Shub 2011년 7월 19일

4 개 추천

Title can take any string. You can use [] and num2str to make a meaningful string that depends on the input to your function
x = 1:3
title(['This figure used x = ', num2str(x)])
In some cases you might want to use sprintf instead of num2str to get a little better control of the formatting.

댓글 수: 2

Liber-T
Liber-T 2011년 7월 19일
Thanks that help, but I still don't know how to give a title to a figure:
exemple:
figure
plot
plot
figure
plot
Here I can put a title on the plot but not on the figure.
Daniel Shub
Daniel Shub 2011년 7월 19일
Where do you want the title to show up? I think
figure
plot
plot
title
figure
plot
title
will work

댓글을 달려면 로그인하십시오.

카테고리

질문:

2011년 7월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by