Find the index of the elements that are between two radii
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have 15 channels of 16 m width with the following internal and external radii:
initial_r = [ 60 76 93 109 125 142 158 174 191 207 223 240 256 272 289 305 ]
I mean there is a channel of 16 m between 60 m and 76 m and so on.
There are particles in these channels that their position change as a function of time, for instance after 10 seconds the position of a particle with the above vector of initial position can be :
Final_r = [ 68 110 70 74 92 192 155 172 170 200 202 204 305 305 305 305 ]
I should find the index of the initial position of the particles that their final position lay in the same channels. for example, there are particles with 3 different initial positions that change to the same final position: 60 m < (68 m, 70 and 74 m) < 76 m, and also there is only one stream with the fianal position between 76 m and 93 m (92 m). I can find how many streams have the same final position but I cannon find the index of which ones. I need a tool that returns me vectors of indices, for instance, for the three streams with the same final position of 60-76 the indices are: index = [1 3 4], or for the one between 76-93 index = [5] but how to find it?
Thanks
0 commentaires
Réponse acceptée
Matt J
le 21 Fév 2019
Modifié(e) : Matt J
le 21 Fév 2019
Perhaps this is what you want?
G=discretize(Final_r,initial_r);
Indices = accumarray(G.',(1:numel(Final_r)).',[],@(z) {sort(z).'})
So what this gives is a cell array such that Indices{k} are the indices of streams belonging to the k-th channel, e.g.,
>> Indices{1}
ans =
1 3 4
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!