How to select array elements based on the elements of another array?
15 ビュー (過去 30 日間)
古いコメントを表示
Kevin Akash Rajasekaran
2021 年 7 月 5 日
コメント済み: Kevin Akash Rajasekaran
2021 年 7 月 5 日
Hey all! I have two double arrays "spiketimes" and "eyetimes". "spiketimes" is 354 elements long and each element is a time point, for eg (0.354 secs etc). Likewise, eyetimes also consists of timepoints but is ~4500 elements long. Now what I want to do is, based on the values of "spiketimes" , I need to select values of "eyetimes" with an interval of 0.02 secs on both sides, so that I pick all the values of eyetimes within that interval. Here's an example to beterr illustrate this
Say, the value I am looking for in "spiketimes" is 0.354 secs. So, In "eyetimes" I need all values between 0.354-0.02 and 0.354+0.02 secs. What might be the best way to go about this? Thanks!!
0 件のコメント
採用された回答
Stephen23
2021 年 7 月 5 日
idx = ismembertol(eyetimes,spiketimes,0.02, 'DataScale',1);
out = eyetimes(idx)
その他の回答 (1 件)
Aparajith Raghuvir
2021 年 7 月 5 日
編集済み: Aparajith Raghuvir
2021 年 7 月 5 日
I understand you're trying to get all the values in an array between two values.
You may use a mask to achieve your objective
mask = eyetimes(eyetimes > (0.354 - 0.02) & eyetimes < (0.354 + 0.02))
required_values = eyetimes(mask)
You may modify the above code to suit your requirement.
I hope this helps.
参考
カテゴリ
Help Center および File Exchange で Electrophysiology についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!