Creating an 8x8 matrix using loops
22 ビュー (過去 30 日間)
古いコメントを表示
Hello eveyone,
I wanted to learn how to create an 8x8 matrix like how it's represented with the pic. I can create it using reshape() bu I want to get the same output using loops.How's that
possible? For and if loop to be more spesific.
1 件のコメント
Ameer Hamza
2020 年 11 月 22 日
What have you already tried for your homework question: https://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
回答 (2 件)
KSSV
2020 年 11 月 22 日
編集済み: KSSV
2020 年 11 月 22 日
Hints:
1. You can generate the number array using ':'. If I want numbers from 1 to 36. I will use
l = 1:36;
2. Once numbers are generated you can use reshape . Read about reshape .
3. After reshape , if the matrix is upside down; you can changed the order using flipud . Read about it.
0 件のコメント
KALYAN ACHARJYA
2020 年 11 月 22 日
編集済み: KALYAN ACHARJYA
2020 年 11 月 22 日
"I can create it using reshape() but I want to get the same output using loops.How's that possible? For and if loop to be more spesific"
You can do that multiple ways, without using any other function, like flip, rot etc. One Way
data=1:64;
mat=zeros(8,8);
k=1;
for i=8:-1:1
idx=k+7*(k-1);
mat(i,:)=data(idx:idx+7);
k=k+1;
end
mat
Please make it more simpler
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Waveform Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!