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

1 回表示 (過去 30 日間)
Matheus Brito
Matheus Brito 2022 年 7 月 1 日
コメント済み: Matt J 2022 年 7 月 1 日
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 Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by