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

 채택된 답변

Star Strider
Star Strider 2022년 4월 29일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Number games에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 4월 29일

댓글:

2022년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by