How do I shift index and keep it as logical?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ivy Chen
am 10 Jul. 2018
Kommentiert: Ivy Chen
am 10 Jul. 2018
I have a index Status as logical and I want to shift it to one row up and one row down as different index array to use for comparison and plotting. I use the following commands:
Last=[NaN;Status(1:end-1)];
Next1=[Status(2:end);NaN];
It creates two new variables, but they become "double", instead of keep them as logical array. Appreciate any help on this.
1 Kommentar
OCDER
am 10 Jul. 2018
Can you show the code that generates Status and uses Last and Next1? Just need to see how the logical indices are being used. Also, a logical index cannot store a NaN value. That's why Last and Next1 are being casted to double matrix instead.
Akzeptierte Antwort
James Tursa
am 10 Jul. 2018
Bearbeitet: James Tursa
am 10 Jul. 2018
Logical values can only be 0 or 1. NaN values can only be kept in double or single class variables. You need to come up with a different scheme for whatever you are doing. Will using false instead of NaN work for your downstream code?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!