Underlining a String or Bolding it

How can I underline the title or put it in bold?
I have the following code:
for j = 1:totalcount
title = sprintf('List of Accelerometers Matching the Selected Criteria (%d of %d)',count,totalcount);
msgbox([title;line;name(:,j)]);
count = count+1;
end
I want to underline the string contained in the variable "title".

댓글 수: 2

John
John 2011년 10월 6일
ignore the variable "line" in msgbox please it should really be the following:
msgbox([title,name(:,j)])
Jan
Jan 2011년 10월 6일
@John: You can edit your question. That's nicer than appending a comment.

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

답변 (1개)

Jan
Jan 2011년 10월 6일

1 개 추천

Bold is possible as TeX command:
Opt.Interpreter = 'tex';
Opt.WindowStyle = 'normal';
msgbox('This text contains a \bfbold\rm word.', 'Title', 'none', Opt);
You can use \it for italics and \color also. But as far as I know, underlining is not possible without using java.

댓글 수: 3

John
John 2011년 10월 6일
I have tried the following with no luck:
Opt.Interpreter = 'tex';
Opt.WindowStyle = 'normal';
for j = 1:totalcount
title = sprintf('\brList of Accelerometers Matching the Selected Criteria (%d of %d)\rm',...
count,totalcount);
msgbox([title;name(:,j)],'List of Accels','none',Opt);
count = count+1;
end
What would you advise?
Walter Roberson
Walter Roberson 2011년 10월 7일
Use \\ instead of \ inside of sprintf()
Jan
Jan 2011년 10월 7일
It is unlikely that "[title;name(:,j)]" will work: therefore "title" and "name(:,j)" name must have the same number of characters. I guess you want a comma instead of a semicolon. A cell string maybe better.
You could find the problem by investigating the intermediate values: What does "sprintf('\brList of Accelerometers Matching the Selected Criteria (%d of %d)\rm', count, totalcount);" reply? SPRINTF interpretes the \ as escape character. So either use the already suggested \\ or:
['\br', sprintf('List of Accelerometers Matching the Selected Criteria (%d of %d)',...
count,totalcount), '\rm'];
Btw, do not overwrite the existing function "title" by a variable.

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

카테고리

제품

태그

질문:

2011년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by