for loop stops when I plot

1 view (last 30 days)
WonJun Choi
WonJun Choi on 10 Jun 2021
Commented: WonJun Choi on 10 Jun 2021
Hi,
I'm trying to plot clustered neuron spikes from 'spikes.mat' data. I used k-means clustering and pca function.
I already have 3 big infuence data index, data clustered index.
But each time I start debug, it stops. My for loop doesn't do 1:size(idx).
My size(idx) is 80397x1 double.
Does anyone know what the problem my code has?
%Spike Sorting
load('spikes.mat'); %detected spikes
[coeff,score,latent,tsquared,explained,mu] = pca(spikes); %PCA analysis
nscore(:,1) = score(:,1);
nscore(:,2) = score(:,2); %score data 정규화
[idx,C] = kmeans(nscore,2); %idx는 군집 인덱스
%Sidx = [nscore, idx];
for k=1:size(idx)
if(idx(k)==1)
figure(1)
title('cluster1 spikes')
plot(nscore(k))
hold on
end
end
for k=1:size(idx)
if(idx(k)==2)
figure(2)
title('cluster2 spikes')
plot(nscore(k))
hold on
end
end
  2 Comments
KSSV
KSSV on 10 Jun 2021
If you do debug, it will stop. You need to quit debug; did you quit debug to proceed to next loop index?
Also
plot(nscore(k))
dont seem to be right.
WonJun Choi
WonJun Choi on 10 Jun 2021
I got my error thx

Sign in to comment.

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!