Save Text as a figure

Hi
I want to save text in a blank figure box (so I can then save it in postscript format). For example if I had A = 15, B = United Kingdom and C = Green I would want to create a figure that would display
Number of people - 15
Location - United Kingdom
Group - Green
so the figure would display text that would be a combination of manually written text and variables A,B and C
Does anyone know how to do this?
Thanks
Andy

 채택된 답변

Jan
Jan 2012년 4월 30일

1 개 추천

A = 15;
B = 'United Kingdom';
C = 'Green';
str = sprintf(['Number of people - %d\n', ...
'Location - %s\n', ...
'Group - %s'], A, B, C);
text(0,0, str);

댓글 수: 1

Friedrich
Friedrich 2012년 4월 30일
I would add an axis off in addition ;)
One can also use an uicontrol:
A = 15
B = 'UK'
C = 'Green'
h = uicontrol('Style','text',...
'Position',[400 45 120 80],...
'String',sprintf('Number of People %d \n Location %s \n Group %s',A,B,C))

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

추가 답변 (1개)

Andy
Andy 2012년 4월 30일

0 개 추천

Answer Works Great, Thanks for both your Answers and thanks again Jan for your response.
Andy

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

태그

질문:

2012년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by