Error: index must be a positive integer or logical.
Ältere Kommentare anzeigen
Hi dear friends.
I am matlab beginer and have a problem about the Error: index must be a positive integer or logical.
That I see in this part of my code.
The error is: Attempted to access Bs(0); index must be a positive integer or logical.
So I wana have a negative value in Bs(0). what should I do?
My code is:
yo=0.1+1.5*i;
Bs=zeros(1,10);
Bs(0)=-(imag(yo));
Akzeptierte Antwort
Weitere Antworten (1)
John D'Errico
am 22 Mai 2019
Bearbeitet: John D'Errico
am 22 Mai 2019
You wrote this:
Bs(0)=-(imag(yo));
MATLAB is not whatever other language you came from. MATLAB has an index origin of 1, NOT 0. That means the first element of an array is indexed with 1.
This is a basic thing, something you would learn in the getting started tutorials.
1 Kommentar
ERFAN AKBARI
am 23 Mai 2019
Kategorien
Mehr zu Common Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!