somebody plz help me with this code. I got an error after run this code is subscript indices must either be real positive integers or logical.

3 views (last 30 days)
for i=1:length(left);
[R_A(i) R_t(i)]=max(sigL(left(i):raight(i)));
R_t(i)=R_t(i)-1+left(i) %add offset
[Q_A(i) Q_t(i)]=min(sigL(left(i):R_t(i)));
Q_t(i)=Q_t(i)-1+left(i)
[S_A(i) S_t(i)]=min(sigL(left(i):raight(i)));
S_t(i)=S_t(i)-1+left(i)
[P_A(i) P_t(i)]=max(sigL(left(i):Q_t(i)));
P_t(i)=P_t(i)-1+left(i)
[T_A(i) T_t(i)]=max(sigL(S_t(i):raight(i)));
T_t(i)=T_t(i)-1+left(i)+47;
end
  4 Comments
Guillaume
Guillaume on 25 Nov 2019
per isakson's reply moved here as well:
You should use Comments to add to your question. From the outside it now looks as if the questions has been answered.
Cannot run your code without some values for the variable sig.
MANISHA KUMARI
MANISHA KUMARI on 26 Nov 2019
new.txt is the ecg raw signal value.
In code there will be an editing of sig=load('new.txt'); instead of sig=load('ecg_60hz_200.dat');

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 25 Nov 2019
%your code:
left=find(difsig==1);
raight=find(difsig==-1);
So left and the mispelled raight are a vector of indices of difsig. They're positive integers that can be any value from 1 to numel(difsig),
%[...]
left=left-(6+16);
raight=raight-(6+16);
From these positive integers you then subtract 10, so they're now integers from -9 to numel(difsig)-9,
%[...]
[R_A(i) R_t(i)]=max(sigL(left(i):raight(i)));
which you're now using as indices. Clearly, there's a problem here since if left or the mispelled raight are less than 1, they can't be used to index.
Unfortunately, the comments don't really explain what you're trying to do, so it's difficult to tell you how to fix it other thanmaking sure that the indices you generate can't be less than 1.

More Answers (1)

Image Analyst
Image Analyst on 26 Nov 2019

Community Treasure Hunt

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

Start Hunting!