How can I extract a submatrix based on rectangles drawn on a map?
Afficher commentaires plus anciens
I have plotted a map (401x401 matrix) and I drew four rectangles on it. I would like to extract 4 submatrices that correposond to the data inside the four rectangles. I'm also trying to extract a fifth submatrix that correpospond to all values outside the four rectangles (I assume this matrix will be 401x401 with zeros at indices already extracted). I tried extracting and plotting many times to get a close submatrix to what I am looking for (below the third comment in the code).
Can anyone please help me with this?
x = 0:25:10000;
y = 0:25:10000;
% map = 401x401 matrix (double)
figure;
imagesc(x,y,map); colormap jet; c=colorbar;
hold on; contour(x,y, map,'k','ShowText','on'); axis xy; xlabel('X (m)'); ylabel('Y (m)');
% Rectangles drawn
rectangle('Position', [3325 3300 3325 4175],'EdgeColor','y','LineWidth',4)
rectangle('Position', [0 0 4100 3300], 'EdgeColor','y', 'LineWidth', 4);
rectangle('Position', [4100 0 5900 3300], 'EdgeColor','y', 'LineWidth', 4);
rectangle('Position', [2525 7475 6000 2525], 'EdgeColor','y', 'LineWidth', 4);
% I tried extracting as follows but I couldn't extract the fifth submatrix
map_seg1 = map(133:301, 138:265);
map_seg2 = map(1:133, 1:164);
map_seg3 = map(1:133, 165:end);
map_seg4 = map(301:end, 102:340);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Time Series Events dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!