index exceeds the number of array elements. Index must not exceed 1.
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Jan
on 30 Dec 2022
Moved: Jan
on 30 Dec 2022
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 Comments
Jan
on 30 Dec 2022
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.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!