フィルターのクリア

Problem with the while loop

2 ビュー (過去 30 日間)
Abhilash
Abhilash 2011 年 8 月 2 日
Hi Guys,
So I have this set of data recorded from a rat. It is presented as a spike-count average and normalised to spikes/s in 5 ms bins.
From the stimulus phase, which consists of 369 bins, i.e. in my case, 369 data points, I need to identify the maximum value and sample 20 points around it including it. Now if the maximum value is somewhere after the 360th time point, it gets messed up of course. So I then need to identify the 2nd maximum and sample. If that is also after 360, then the third max and so on.
So I wrote this stretch of code for it. The while loop gets stuck and refuses to go on. It doesn't give me an error, but it just stays at 'Busy' and doesn't end.
samp_resp = [];
for k = 1:size(stim_resp,1)
m = max(stim_resp(k,:));
c = find(stim_resp(k,:)==m);
while c>=size(stim_resp,2)-((win/2)-1)
u_stim_resp = unique(stim_resp(k,:));
max2nd = u_stim_resp(end-1);
c = find(stim_resp(k,:)==max2nd);
end
samp_resp1 = stim_resp(k,c-(win/2):c+((win/2)-1));
samp_resp = [samp_resp;samp_resp1];
end
I'd be very grateful if someone could help me out please.
Thanks.

採用された回答

Abhilash
Abhilash 2011 年 8 月 2 日
Ah shoot sorry, nevermind. I'm not going to look for a 2nd max. Makes no sense. I'll just sample how many ever points are left after and make up to 20 with points before that.
Thanks though!

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 8 月 2 日
Why not just find max() of Array(win/2 : end - win/2 + 1) ? You can then add win/2 - 1 to that index to find the original position.
  1 件のコメント
Abhilash
Abhilash 2011 年 8 月 2 日
I'm sorry, I don't understand. Could you please explain it a little more for a newbie? :)

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by