1

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.

2 Answers 2

4
message = sprintf('Your answer is %d', var)
msgbox(message)
Sign up to request clarification or add additional context in comments.

Comments

1

this is going to work too

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.