Find exceeds array ERROR
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Neda Deljavan
el 23 de En. de 2023
Editada: Les Beckham
el 23 de En. de 2023
Hello everybody,
I came across with this error in my code which is below, What should I do to fix it?
Code:
%% step15: Phase Locking Value (PLV)
% How well waves' phases are locked in a phase synchrony. The main idea is
% to take the phases of waveforms by taking into account the real part of the Hilbert Transform of signals.
% Then applying the equation.
%Here we take phases for subject one. Variable " phis " is then the phases of 91 signals of subject one.
sujeto = 1;
phis = angle(hilbert(subs_cd1_al(:,:,sujeto)'));
% Now computing PLV over phases "phis" of subject one.
pairs = nchoosek(1:4,1); % all combinations of 4 channels
plv = zeros(4,4);
for pr = 1 : length(pairs)
plv(pairs(pr,1), pairs(pr,2)) = abs(sum(exp(1i* ( phis(:,pairs(pr,1)) - phis(:,pairs(pr,2)) ))))/length(phis);
end
plv = plv + plv'; % we take its transpose to create the connectivity matrix
figure
imagesc(plv);colorbar;
axis square; colorbar
title('PLV')
Error:
Index in position 2 exceeds array bounds (must not exceed 1).
Error in NEW1 (line 296)
plv(pairs(pr,1), pairs(pr,2)) = abs(sum(exp(1i* ( phis(:,pairs(pr,1)) - phis(:,pairs(pr,2)) ))))/length(phis);
0 comentarios
Respuesta aceptada
Les Beckham
el 23 de En. de 2023
Editada: Les Beckham
el 23 de En. de 2023
One obvious problem with this code is where you try to access pairs(pr,2) but pairs is a one dimensional (4x1) vector. Perhaps you need to revise the definition of pairs?
pairs = nchoosek(1:4,1)
Maybe you meant this?
pairs = nchoosek(1:4,2)
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!