Index a 2D matrix from a 2D matrix

조회 수: 1 (최근 30일)
BBB
BBB 2019년 11월 12일
댓글: Matt J 2019년 11월 12일
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
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
Walter Roberson
Walter Roberson 2019년 11월 12일
Perhaps you should be looking at conv2() ?
Matt J
Matt J 2019년 11월 12일
Perhaps you should be looking at conv2() ?
As I also mentioned in your duplicate post here,

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by