Taking data points in between multiple interval times times and outputting them in separate structural arrays
1 次查看(过去 30 天)
显示 更早的评论
I have spike times in one matrix. I then have time intervals, start and stop times, that I would like to get all the spike times in between. I believe I could use bsxfun and @ge function to do this, but I would like to have each interval of extracted spikes time outputted into separate structural arrays. The field names do not matter for the structural array and can be the same. I think I can use the struct function, but I have had issues on how to use these two functions in the way I want.
To sum, I have intervals, Start time and Stop time, in one matrix (intervals) and I want to get corresponding spike times (spiketimes) from each interval of another matrix and output them into individual structural arrays for each interval. I have attached example matrices of what the two matrices look like.
0 个评论
采纳的回答
John BG
2016-6-11
Heath
spiketimes=spiketimes' % just to visualise horizontally
[sz1_intervals sz2_intervals]=size(intervals)
% init containers of variable length for found spikes within each interval
for k=1:1:sz1_intervals
spk{k}={}
end
for k=1:1:sz1_intervals
w=intervals(k,:);
spk{k}=intersect(spiketimes(find(spiketimes>=w(1))),spiketimes(find(spiketimes<=w(2))));
end
each group of spikes is contained in respective cells:
spk{1}
=
=
Columns 1 through 5
60.18 60.18 60.18 60.18 60.18
Columns 6 through 10
60.18 60.19 60.19 60.19 60.19
..
64.93 64.93 64.94 64.94 65.02
Columns 81 through 84
65.02 65.02 65.04 65.05
spk{2}=
..
spk{3}=
..
If you find this answer of any help solving your question,
please mark this answer as accepted,
thanks in advance
John
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!