i keep getting an error for the messagebox.

1 Ansicht (letzte 30 Tage)
Isobel Leikis
Isobel Leikis am 29 Apr. 2022
Kommentiert: Star Strider am 30 Apr. 2022
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

Akzeptierte Antwort

Star Strider
Star Strider am 29 Apr. 2022
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 Kommentare
Isobel Leikis
Isobel Leikis am 30 Apr. 2022
It worked, thank you!
Star Strider
Star Strider am 30 Apr. 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Just for fun finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by