Find the index of the elements that are between two radii
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matt J
2019년 2월 21일
편집: Matt J
2019년 2월 21일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!