How do you insert a changing variable into an input command?

So for example,
for k=1:5 & i=1:5
x(k)=input('Enter value of (i) state')
end
For the above I want 5 input commands asking for the value of the state.
Enter value of 1 state,
Enter value of 2 state,
Enter value of 3 state, etc.
The code above does not seem to give that, any help please I am a novice user of Matlab. Thank You

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 17 日
編集済み: Azzi Abdelmalek 2013 年 2 月 17 日

2 投票

for k=1:5
x(k)=input(sprintf('Enter value of %d state',k))
end

その他の回答 (1 件)

Umer Alam
Umer Alam 2013 年 2 月 17 日

0 投票

Thanks a lot for both responses I spent many hours finding out, should have used this Mathwork site first. Peace

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by