For Loop Problem error
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shalaw faraj
am 15 Jul. 2019
Kommentiert: shalaw faraj
am 15 Jul. 2019
img=imread('C:\Users\Shalaw\Downloads\gray.jpeg');
[n,m]=size(img);
part1=img(1:n/2,1:m/2);
part2=img(1:n/2,(m/2)+1:end);
part3=img(n/2+1:end,1:m/2);
part4=img(n/2+1:end,m/2+1:end);
for i=1:4
subplot(2,2,i);
imshow(part1); -----> I want to change 1 to i, but i cant please help.
end
1 Kommentar
Akzeptierte Antwort
Adam
am 15 Jul. 2019
img=imread('C:\Users\Shalaw\Downloads\gray.jpeg');
[n,m]=size(img);
part{1}=img(1:n/2,1:m/2);
part{2}=img(1:n/2,(m/2)+1:end);
part{3}=img(n/2+1:end,1:m/2);
part{4}=img(n/2+1:end,m/2+1:end);
for i=1:4
subplot(2,2,i);
imshow(part{i});
end
Weitere Antworten (1)
Andrei Bobrov
am 15 Jul. 2019
img=imread('C:\Users\Shalaw\Downloads\gray.jpeg');
[n,m]=size(img);
imgs = mat2cell(img,[n,n]/2,[m,m]/2)';
for ii = 1:4
subplot(2,2,ii);
imshow(imgs{ii});
end
3 Kommentare
Andrei Bobrov
am 15 Jul. 2019
k = 4;
[n,m]=size(img);
imgs = mat2cell(img, n/k*ones(1,k), m/k*ones(1,k))';
for ii = 1:k^2
subplot(k,k,ii);
imshow(imgs{ii});
end
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!