variable into msgbox???

조회 수: 11 (최근 30일)
alexis
alexis 2011년 7월 19일
How do I display a variable's value on a msgbox? I have (1x9) array :
k =
Columns 1 through 7
[1x27 char] [1x36 char] [1x35 char] [1x32 char] [1x28 char] [1x27 char] [1x34 char]
Columns 8 through 9
[1x23 char] [1x34 char]
I try that but it didn't work:
>> msgbox(['These values are incorrect', 'WARNING','warn'], k)
??? Error using ==> figure Value must be a string
Error in ==> dialog at 88 hDialog = figure('BackingStore' ,backstore , ...
Error in ==> msgbox at 223 figureHandle=dialog( ...
Can you help me??

채택된 답변

Jan
Jan 2011년 7월 19일
The 2nd input of MSGBOX is a string containing the dialog's title. See "help msgbox".
msgbox(cat(2, {'These values are incorrect:'}, k), 'Warning')
The CAT command joins the single cell string with the list of strings in the cell string k to create the message.
  댓글 수: 1
alexis
alexis 2011년 7월 19일
Thanks Jan
You really help me a lot!!!
Many thanks!

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

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 7월 19일
Use sprintf to make a string:
msgbox(sprintf('These Values are incorrect WARNING %f warn',k))
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2011년 7월 19일
k{:}
Jan
Jan 2011년 7월 19일
k{:} will not help also, because the '%f' format expects a floating point number, but k contains strings. Perhaps you want this:
['These Values are incorrect WARNING', char(10), ...
sprintf('%s\n', k{:})].

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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by