index exceeds array bounds
이전 댓글 표시
%%%%I am trying to create a programm which gets values from an excel file
for fl=1:1:dof(de,4)
for i=1:1:ne
CKx(fl)=sum(b(i)*ckx(i))./sum(b(i));
CKy(fl)=sum(c(i)*cky(i))./sum(c(i));
end
end
댓글 수: 9
Chaudhary P Patel
2020년 9월 30일
Chaudhary P Patel
2020년 9월 30일
KSSV
2020년 9월 30일
If you try to access more number of elements then present, then you will get this error.
A = rand(1,5) ;
A(6) % error
Chaudhary P Patel
2020년 9월 30일
Chaudhary P Patel
2020년 9월 30일
KALYAN ACHARJYA
2020년 9월 30일
편집: KSSV
2020년 9월 30일
@KSSV shown an example for a similar error. Suppose you have an array "A" having length 5
A = rand(1,5) ;
Now if you want to access the 6th index element of A,then it shows the simmilar error, as A have length 5th only.
A(6) % error
Same case may happen in your code, you want to access the particular index element from the data file, but its exceeds its actual length/size
Chaudhary P Patel
2020년 9월 30일
KALYAN ACHARJYA
2020년 9월 30일
Sir, Sure I will try
KSSV
2020년 9월 30일
@Pramod we cannot help you unless we know your complete code and the variables.
답변 (1개)
KSSV
2020년 9월 30일
m = dof(de,4) ; % I hope this is a number
ne = length(b) ; % dimensions of b and ckx, cky should be same
Ckx = cell(m,ne) ; % cell because I assume the ouput stored is array as you have used ./
Cky = cell(m,ne) ;
for fl=1:1:m
for i=1:1:ne
CKx{fl,i}=sum(b(i)*ckx(i))./sum(b(i));
CKy{fl,i}=sum(c(i)*cky(i))./sum(c(i));
end
end
카테고리
도움말 센터 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!