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

 Respuesta aceptada

Star Strider
Star Strider el 29 de Abr. de 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 comentarios

Isobel Leikis
Isobel Leikis el 30 de Abr. de 2022
It worked, thank you!
Star Strider
Star Strider el 30 de Abr. de 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Number games en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Preguntada:

el 29 de Abr. de 2022

Comentada:

el 30 de Abr. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by