How can i create a square matrix from values that user inputs in a script?

2 ビュー (過去 30 日間)
Arafa-Dilip
Arafa-Dilip 2017 年 5 月 28 日
コメント済み: Arafa-Dilip 2017 年 5 月 29 日
The code for inputting values from the user is:
for i=1:n
fprintf ('enter value %d: ',i);
a(i)=input ('');
end
%Now how can I arrange those values into a square matrix?

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 28 日
reshape(a, sqrt(n), [])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by