필터 지우기
필터 지우기

why do i recieve Index exceeds matrix dimensions error ?

조회 수: 2 (최근 30일)
HamidReza Saleh
HamidReza Saleh 2017년 6월 24일
댓글: HamidReza Saleh 2017년 6월 24일
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
dpb
dpb 2017년 6월 24일
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 2017년 6월 24일
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

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by