Access Matrix using array as keys
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a matrix
allPoints = ["10999970X10999700Y" "11000310X12099960Y" "10999970X12999700Y";
"11999970X10999960Y" "11999970X12000230Y" "11999970X13000230Y";
"12999970X10999700Y" "12999970X12000230Y" "12999970X13000230Y"]
And I want to select points based of rectangles, where I have bottom and top points of the rectangle
For a single rectangle with
bottom = [1 1]; top = [2 2];
I would use:
coveredPoints = allPoints(bottom(1):top(1),bottom(2):top(2))
%% OUTPUT
% coveredPoints =
%
% 2×2 string array
%
% "10999970X10999700Y" "11000310X12099960Y"
% "11999970X10999960Y" "11999970X12000230Y"
which would return all the points from (1,1) to (2,2).
But now I have multiple bottoms and tops, and I want to get all the covered areas into a n x 1 array (single column array)
bottoms = [1 3; 2 2]; tops=[1 3; 2 2];
% When I try
coveredPoints = allPoints(bottoms(:,1):tops(:,1), bottoms(:,2):tops(:,2));
% It only returns the values for the first row only
% coveredPoints =
%
% "10999970X12999700Y"
Is there a way to extract all covered points onto a n x 1 array without a loop?
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!