muaaQ
muaaQ

Reputation: 39

Matlab Display variable output in dialog box

I would like to display in the message dialog box the output of a variable.

msgbox('Your answer is   ');

The variable's name is var and it equals 2. How may I edit the code so that I display the value of that variable there (where the blank space is)?

Input would be much appreciated.

Upvotes: 1

Views: 3356

Answers (2)

user3102903
user3102903

Reputation: 33

this is going to work too

     msgbox(['Your answer is=   ',num2str(var)]);

Upvotes: 1

chris
chris

Reputation: 5006

message = sprintf('Your answer is %d', var)
msgbox(message)

Upvotes: 4

Related Questions