フィルターのクリア

Find the index of the elements that are between two radii

2 ビュー (過去 30 日間)
Maryam S
Maryam S 2019 年 2 月 20 日
コメント済み: Maryam S 2019 年 2 月 21 日
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

採用された回答

Matt J
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
  1 件のコメント
Maryam S
Maryam S 2019 年 2 月 21 日
Wow! This is exactly what I need! Thank you so much!

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2019 年 2 月 21 日
編集済み: Matt J 2019 年 2 月 21 日
index = (Final_r>=initial_r) & (Final_r<[initial_r(2:end),inf])
  1 件のコメント
Maryam S
Maryam S 2019 年 2 月 21 日
編集済み: Maryam S 2019 年 2 月 21 日
Thanks Matt J for the quick answer, but I think I did not well explain what I meant. I edited my question, tak a look if you are still interested in helping with me.
Thanks
Maryam

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by