简体   繁体   English

在inputdlg框中显示循环计数的值?

[英]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 : 使用sprintf

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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