Mapping arrays based on repeating integers in a vector
Afficher commentaires plus anciens
%%make some fake data
A=(1:5)'
B=zeros(10,1)
B(1:2:end)=A(1:1:end)
B(2:2:end)=A(1:1:end)
B(3)=1
B(9)=4
D=(rand(10,2))*100;
E=horzcat(B,D)
E(11,:)=[5,40,66.1]
%%******************************************************************
maxnum=max(E(:,1))
%%******************************************************************
% Need to map the values from columns 2&3 for the rows where they have the
% same value in the first colum. I could write a loop that will split them up
% into the 1's, 2's and 3's but I am wondering if there is a tidier vector
% approach using logical or relative indexing
%%******************************************************************
Z=unique(E(:,1));
%%******************************************************************
for k=1:length(Z)
S{k}= find(E(:,1)==k);
end
Hi,
I have been looking through questions on here and stack overflow and wondered if anyone has any pointers? I have a large dataset of coordinates of objects taken from multiple frames. I have an index as to which frame the coordinates are taken. I would like to either split up the array or be able to index that portion of the array which corresponds to the frame I am interested in to analyse. I have tried a few methods involving loops, none of which worked particularly well, the example above has the frame info in the cell array S but its an ugly way to do it and want to know if there is a better way.
Best regards
Steve
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Resizing and Reshaping Matrices 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!