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

1 Ansicht (letzte 30 Tage)
Sameer
Sameer am 13 Mai 2014
Bearbeitet: Andreas Goser am 13 Mai 2014
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?

Antworten (1)

Andreas Goser
Andreas Goser am 13 Mai 2014
Bearbeitet: Andreas Goser am 13 Mai 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.

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!

Translated by