index exceeds matrix dimensions

3 views (last 30 days)
I would appreciate if anyone could advise as to why I am receiving this error. note, x is a multiple of windowSize.
cheers Christy Burger
clear; clc; close all;
x = load('RotationSpeed.csv');
windowSize = 10;
b = (1/windowSize)*ones(1,windowSize);
ii = 1;
yTemp = 0;
for n = windowSize-1: length(x)
m = 0;
for j = 1 : windowSize
temp = b(j)*x(n-m);
yTemp = yTemp + temp;
m = m - 1;
n = n + 1;
end
y(ii,:) = [yTemp];
ii = ii+1;
yTemp = 0;
end

Accepted Answer

James Tursa
James Tursa on 23 Feb 2018
Type the following at the command line:
dbstop if error
Then run your code. When the error occurs, the debugger will pause the code at the line of the error with all variables intact. Examine them for dimensions and for the indexing you are using on that line. Then figure out why the dimensions or indexing is not what you expected.
  1 Comment
Christopher Manby
Christopher Manby on 25 Feb 2018
Solved it. Thank you very much for the advice. I won't forget this one!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!