i keep getting an error for the messagebox.

prompt= 'What is your name?';
name = inputdlg(prompt);
msgbox(fprintf("Hello %s, in this game, you must answer the question correctly to progress and avoid being attacked", name));
% i have tried sprintf and no print command withing the msgbox command and i cant seem to stop recieving the same error

 Accepted Answer

The ‘name’ variable is a cell array, so it must be addressed as such. Also, fprintf is not appropriate here, however sprintf is.
Try this:
msgbox(sprintf("Hello %s, in this game, you must answer the question correctly to progress and avoid being attacked", name{:}));
.

2 Comments

It worked, thank you!
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Categories

Find more on Number games in Help Center and File Exchange

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!