Clear Filters
Clear Filters

why do i recieve Index exceeds matrix dimensions error ?

2 views (last 30 days)
Hi
im trying to calculate 70 different variables FDOST to do this i tried to put them in a for loop like this :
for i=1:70
for j=1:3
b(i)=FOST_1D_DEC(a(i(x:aa,j)));
end
if i>=5
x=x+5;
end
end
first i put all 70 variables to a variable named "a" by the command a=[ ] , as my variables are about 40001x3 , "a" becomes 40001x210 .
i want to calculate FDOST for each variable from different starting point for example :
b=FOST_1D_DEC(a1(20280:20280+1023,1));
but all the time i run my script i receive index matrix error. Another problem is that as i checked a(1) is not matrix with dimension of 40001x3 anymore and to solve it it should return a matrix with dimension of 40001x3, could anyone give me a suggestion how to solve the problem ???
p.s: x variable is defined by the user for example 20280 and as FDOST only works with multiplies of two i add x with 1023 which gives me aa like this aa=x+1023 another things to explain is that x should after each loop of j complete add with five to makes starting point different
  4 Comments
dpb
dpb on 24 Jun 2017
The comment on syntax KSSV has nothing to do with the sizes, it's that FOST_1D_DEC(a(i(x:aa,j))) is simply incorrect and impossible syntax. The innermost nesting of parens i(x:aa,j) is array indexing notation for i which is the loop variable and hence can only be one value each iteration.
Your posted code cannot be the actual code...we would need a complete section of code that includes all the input variables in order to be able to track down where the dimension errors really arise; as it is totally new code to all of us and we really don't know just what you're trying to accomplish, it's likely if you will use the debugger and step through the code line by line you'll be able to see where you've made a logic error that doesn't return what you intended for subscripts.
It would likely help in debugging to make the problem space much smaller so you can see the arrays in the command window more easily; 4 columns are just as effective in debugging logic as are 4000.
HamidReza Saleh
HamidReza Saleh on 24 Jun 2017
Thank you guys by this changes i just fix it myself thanks for you're feedback
for i=1:70
for j=1:3
b(i,j,:)=FOST_1D_DEC(a(x:x+1023,3*(i-1)+j));
end
x=x+5;
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!