Find the index of the elements that are between two radii
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Maryam S
am 20 Feb. 2019
Kommentiert: Maryam S
am 21 Feb. 2019
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 Kommentare
Akzeptierte Antwort
Matt J
am 21 Feb. 2019
Bearbeitet: Matt J
am 21 Feb. 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
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!