简体   繁体   中英

display the value of a loop count in inputdlg box?

apologies for the rather vague question, i've written a simple for statment, where players is a predetermined integer:

for k = 0:players;
    inputdlg('Enter the name of player (?): ');
end

i'd like to have the section (?) to be automatically populated as the statement counts through the player number. can anyone suggest a way to do this? thanks!

Use sprintf :

for k = 0:players
    st = sprintf('Enter the name of player %d',k);
    inputdlg(st);
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM