how can i get in place of %d is i values for each iteration of e

5 ビュー (過去 30 日間)
Ganesh budi
Ganesh budi 2018 年 6 月 12 日
回答済み: Ganesh budi 2018 年 6 月 13 日
num_nod=input('num_nod = ')
for e=1:2*num_nod
force(e,1)=input('applied forces at node %d:',e);
end

採用された回答

Geoff Hayes
Geoff Hayes 2018 年 6 月 12 日
Ganesh - use sprintf to create your string for the input command
force(e,1) = input(sprintf('applied forces at node %d:',e));
Also, pre-allocate memory to the force array so that it doesn't need to increase size on each iteration of the loop. i.e.
num_nod=input('num_nod = ')
force = zeros(2*num_nod,1);
for e=1:2*num_nod
force(e,1) = input(sprintf('applied forces at node %d:',e));
end

その他の回答 (1 件)

Ganesh budi
Ganesh budi 2018 年 6 月 13 日
thanks sir

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by