Why do I receive the array indices must be positive intergers or logical values

1 次查看(过去 30 天)
Hi everybody,
I receive this error everytime (bold line). Someone can help me?
%Arquivo dos dados do olhar ao longo do tempo
pupila=dados(:,1); %cria variável do diâmetro da 'pupila' correspondente
Unrecognized function or variable 'dados'.
freq=60;
timetime = (1:length(pupila))/freq;
tempo = timetime';
%Arquivo dos dados da lista de fixações
fix_ini=xdados(:,2); %cria variável do tempo de início de cada fixação
fix_ini=fix_ini(fix_ini>5 & fix_ini<65); %delimita os tempos de início das fixações entre 5 e 65 segundos em cada tentativa
fix_num=length(fix_ini); %cria variável com o número de fixações da tentativa (entre 5 e 65seg)
%Cria variáveis com zeros a serem posteriormente preenchidas (no
%loop abaixo)
pupil_fix=zeros(fix_num,181);
pupil_fix_filt=zeros(fix_num,181);
pupil_dilation=zeros(fix_num,181);
%Loop para delimitar os dados da pupila relativos a cada início de fixação
%(com 60 pontos de dados anteriores [1s] e 120 posteriores [2s]; o início
%da fixação é a referência de 0s - total 181 pontos de dados)
for i=1:fix_num
fix_time=fix_ini(i); %define cada início de fixação
tempo_fix=xdados(:,3);
pupil_fix(i,:)=pupila(tempo_fix-60:tempo_fix+60); %delimita os dados da pupila no período)
end

回答(1 个)

Matt J
Matt J 2022-7-1
You haven't provided the input necessary to run your code, but it looks like tempo_fix-60 could be <=0.
  4 个评论
Matheus Brito
Matheus Brito 2022-7-1
yes, andthe follow message appear:
The logical indices contain a true value outside of the array bounds.
Error in rotinapupilometriafinal (line 60)
pupil_fix(i,:)=pupila(tempo_fix-60<=0:tempo_fix+60); %delimita os dados da pupila no período)
Matt J
Matt J 2022-7-1
tempo_fix is a 109x1 vector of non-integer values, so it is not clear what the 3rd line in the loop is supposed to do.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by