Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

getting error "Index exceeds matrix dimensions"

2 visualizzazioni (ultimi 30 giorni)
Mirbahar Naadiya
Mirbahar Naadiya il 16 Nov 2017
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Can someone can help me to find out the error
if true
% code
i=1;
j=1;
windowsize=50;
[m,n]=size(accX);
avgX=zeros(m,1);
%*******In each iteration, statistical values of a window are calculated
%and raw data(accX) index is inceremented by windowsize/2 to
%provide %50 overlapping*****%
while(i<=m)
avgX(j)=mean(accX(i:i+windowsize-1));
i=i+windowsize/2-1;
j=j+1;
end

Risposte (1)

Star Strider
Star Strider il 16 Nov 2017
Try this instead:
i=i+windowsize;
  2 Commenti
Mirbahar Naadiya
Mirbahar Naadiya il 16 Nov 2017
yeah thank u am not getting the error now but all the values of variable avgX is zero. Can u guide me to get mean of the data through sliding window
Star Strider
Star Strider il 16 Nov 2017
That depends on what ‘accX’ is, and its size. Your code worked for me with a vector I created, and produced the three values I expected when ‘accX’ was a (150x1) vector.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by