Azzera filtri
Azzera filtri

Attempted to access B(25,1); index must be a positive integer or logical.

1 visualizzazione (ultimi 30 giorni)
rowsCI = rows(swtCI);
B = sort(PQMatx(:,3)); h=1; while h<=rowsCI; UB=(1-swtCI(h,1)); UBB=UB/2; UBBB=1-UBB; UBBBB = UBB*swtN; J = B(UBBBB,1); disp('Upper Bound for swtCI(i,1)'); disp(J); M = B((((1-swtCI(h,1))/2)*swtN),1); disp('Lower Bound for swtCI(i,1)'); disp(M); h=h+1; end;
this is my code. why cant matlab access and display negative numbers?

Risposte (1)

Andreas Goser
Andreas Goser il 13 Mag 2014
Modificato: Andreas Goser il 13 Mag 2014
It is not about "access and display negative numbers", it is about the indices. Like you would try to access B(-1) or B(1.2).
Verify the values with in the B(<value>) brackets. When you put this in a script and not execute from the command line, you also get a line number where to debug.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by