Index a 2D matrix from a 2D matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I have a 600x1000 dim 2D matrix and I want to use a nested for loop to index out a 51x51 matrix out of it. How can we do that? It has to be in a nested loop format of--
for ii = 1:1000
for jj = 1:600
...
Thanks.
回答 (1 件)
Arash Rabbani
2019 年 11 月 12 日
Well you can simply do this without a loop:
A=rand(600,1000);
B=A(1:51,1:51);
But if you need it to use loops
B=zeros(51);
for ii = 1:51
for jj = 1:51
B(ii,jj)=A(ii,jj);
end
end
3 件のコメント
Matt J
2019 年 11 月 12 日
Perhaps you should be looking at conv2() ?
As I also mentioned in your duplicate post here,
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!