index exceeds the number of array elements. Index must not exceed 1.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Jan
am 30 Dez. 2022
Verschoben: Jan
am 30 Dez. 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 Kommentare
Jan
am 30 Dez. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!