For Loop Indexing exceeding array elements
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi I'm trying to make a loop that runs from k=o to k=300 and use the values for some equations from the previous iteration. I can't get it to run without it saying "Index exceeds the number of array elements (1)."
댓글 수: 0
답변 (1개)
David Fletcher
2021년 4월 4일
편집: David Fletcher
2021년 4월 4일
First run of the loop you are overwriting the z vector with a scaler
if k <= 1
z=5;
mu = 0;
On subsequent runs of the loop you are trying to index the vector that you overwrote with a scaler on the first pass
댓글 수: 1
David Fletcher
2021년 4월 4일
Without going through the code in microscopic detail, just as a general observation - you've got an awful lot of zeroes kicking around in those arrays set to zero at the start, so any sort of misindexing is likely to result in multiplication by zero - hence getting an awful lot of nothing at the end
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!