I can I do logical indexing on a column
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Engdaw Chane
il 20 Lug 2018
Commentato: Engdaw Chane
il 20 Lug 2018
Hello everyone,
I have a column which is 840 in length. It contains value s from -12 to 12. I need only values < -8 and >8. I need to keep the length 840. I tried the following. but it says " 0x1 empty double column vector".
v = zeros (size (data)); % Pre-allocate!
v=data(data <-8 & data>8)
thank you for helping.
Chane
0 Commenti
Risposta accettata
Birdman
il 20 Lug 2018
Modificato: Birdman
il 20 Lug 2018
Is it possible for a value to be smaller than -8 and greater than 8 at the same time? Check your logical operator. You need OR operator instead of AND.
v=data(data <-8 | data>8)
You can not keep the length same. If you want that, fill the other values with a specific value, like zero.
5 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Cell Arrays 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!