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

1 view (last 30 days)
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

Answers (1)

Matt J
Matt J on 1 Jul 2022
You haven't provided the input necessary to run your code, but it looks like tempo_fix-60 could be <=0.
  4 Comments
Matheus Brito
Matheus Brito on 1 Jul 2022
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 on 1 Jul 2022
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.

Sign in to comment.

Categories

Find more on Get Started with MATLAB 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!