index exceeds the number of array elements. Index must not exceed 1.
조회 수: 2 (최근 30일)
이전 댓글 표시
j = 0;
for j = 1:class_size
if (Z(j) <= ZNew(j)); % Here we compare the new versus the max
X(j,:) = Xnew(j,:);
Z(j) = ZNew(j); % If new is better
end
X(j,:) = max(X(j,:),LL);
X(j,:) = min(X(j,:),UL);
end
Index exceeds the number of array elements. Index must not exceed 1.
Error in drjuri (line 79)
if (Z(j) <= ZNew(j)); % Here we compare the new versus the max
I tried to change j = 2 but problem still the same. What am i missing here what should i assign?
thanks.
댓글 수: 0
채택된 답변
Jan
2022년 12월 30일
이동: Jan
2022년 12월 30일
Omit the confusing
j = 0;
It does not have any effect, because the for j command overwrites the value immediately.
If Z and/or ZNew are scalar values, there is no Z(2) and/or ZNew(2). You did not include the definition of these variables, so the actual problem is hidden yet.
댓글 수: 2
Jan
2022년 12월 30일
If you append a trailing end, the code can be started. It stops with the error message:
Undefined function or variable 'f1'.
f2 is missing also.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!