Converting to a square matrix
古いコメントを表示
In `MATLAB`, say that we have a matrix with the following dimensions:
[11036,1]
How can we convert that to a square matrix?
Thanks.
採用された回答
その他の回答 (1 件)
Image Analyst
2014 年 2 月 19 日
Since sqrt(11036) is not an integer, are you okay with clipping off some elements?
aNew = a(1:(105*105)); % Extract the proper number of elements.
aNew = reshape(a, [105, 105]); % Make 2D square.
2 件のコメント
med-sweng
2014 年 2 月 19 日
Image Analyst
2014 年 2 月 20 日
Yes, looks like Jos answered before I could. I'm not sure if you knew in advance that the matrix could not be square when you asked, but if you did, you could have gotten a quicker answer if you had specified whether to clip or pad in your original question. I assumed the clipping option when you evidently wanted the padding option. I guess I could have guessed at both ways but it would be better if you just state all your requirements up front so we don't have to guess.
カテゴリ
ヘルプ センター および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!