Problem by creating Sub Matrices
Mostra commenti meno recenti

I have 5x5 matrix.I want to create 6 submatrices of order 3x3.Uploaded the pic please any one can do it.Or any other methods to do this operation.Thanks
Risposta accettata
Più risposte (1)
MSP
il 25 Ago 2017
clear all
a=magic(5)
shiftr=2
shiftc=1
k=1
rowsize=3
colsize=3
for i=1:shiftr:size(a,1)
if i+rowsize-1>size(a,1) %%check whether b matrix indices is within a If not then break-i loop
break
end
for j=1:shiftc:size(a,2)
if (j+colsize-1)>size(a,2)
break
else
b(:,:,k)=a(i:i+rowsize-1,j:j+colsize-1)
k=k+1;
end
end
j=1;
end
This is the most basic format of doing it.Have a look and ask if u don't understand.
1 Commento
Haseeb Hassan
il 26 Ago 2017
Modificato: Haseeb Hassan
il 26 Ago 2017
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!