Tags: box, boxthe, display, following, inmessage, istit, matlab, message, programming, sens288message, syntax, value, variable

how to display value of variable in a message box

On Programmer » Matlab

1,285 words with 2 Comments; publish: Wed, 07 May 2008 11:50:00 GMT; (20046.88, « »)

i have a very simple problem... i want to display few results in

message box

the syntax i am following is

tit='RESULT';

sens=288;

message= 'Sensitivity ' +sens;

message=[message;' is the result '];

msgbox(message,tit);

the value of variable sens does not appear either it gives an error or

gives strange characters as output.

plz reply n help me...

thanx in advance

Regards,

All Comments

Leave a comment...

  • 2 Comments
    • i presume you need to use the brackets [] to perform the string

      concatenation but also you need to convert your numerical information

      to a string prior to the concatenation.

      message = ['Sensitivity ', num2str(sens)];

      also you should remember when working with strings, when performing the

      string concatenation ',' results in column concatenation while ';'

      results in row concatenation, so i believe:

      message = [message ; ' is the result'] results in a two line result

      whereas

      message = [message , ' is the result'] does not.

      #1; Wed, 07 May 2008 11:51:00 GMT
    • hi,

      you can fix it as shown below:

      tit='RESULT';

      sens=288;

      message= ['Sensitivity' ' ' num2str(sens) ' is the result ']

      msgbox(message,tit);

      good luck

      #2; Wed, 07 May 2008 11:52:00 GMT