Subscript indices must either be real positive integers or logicals.

조회 수: 4 (최근 30일)
Alyna
Alyna 2014년 12월 9일
댓글: Alyna 2014년 12월 9일
I am trying to find the on/off times of EMG data, but MATLAB is giving the following error for the line with stars in my code:
Subscript indices must either be real positive integers or logicals.
I'm not sure what this means for my data. Any explanations would be helpful.
%%Find the on/off times of the EMG data within each rep
i = 1;
j = 1;
for r = 1:length(spans(:,1))
if spans(r,1) == 1 && spans(r-1,1) == 0
%The first marker point
first_marker = r;
end
end
thresh = 2.*std(EMG(1:first_marker));
for a = 1:7
EMGreps = Repetitions{1,a};
for c = 1:7
for r = 1:length(EMGreps)
if EMGreps(r,1) > thresh && EMGreps(r-1,1) < thresh
% Determines if the EMG data is on
On_EMG(i,c) = r/sampRate;
i = i + 1;
end
*** if EMGreps(r,1) < thresh && EMGreps(r-1,1) > thresh
% Determines if the EMG data is off
Off_EMG(j,c) = r/sampRate;
j = j + 1;
end
end
end
end
  댓글 수: 2
Image Analyst
Image Analyst 2014년 12월 9일
Like almost everyone else, you don't include the full error message. Please copy and paste ALL THE RED TEXT - don't just snip out a small part of it that leaves out the crucial information like what line of code the error happened at.
Alyna
Alyna 2014년 12월 9일
Actually, I did copy the entire error message. The only other line was commenting on the line in question, which I wrote about.

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 12월 9일
Alyna - the error message is telling you that an index into an array must be a positive integer or logical. In your case, you are trying to use zero as an index into EMGreps at
EMGreps(r-1,1)
which is the second condition in both of your if statements. Note how the index variable r starts at one, and so r-1 is zero. Start this variable at two and you should be good to continue
for r=2:length(RMGreps)
% etc
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by