Remove cell array rows based on logical condition?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Howdy,
I have a 2267x23 cell array (raw). I would like to remove rows based on the condition of a logical.
Here is what I've done:
I = num(:,20) == 1 | num(:,20) == 7; % Makes logical index for weekend (1 = weekend, 0 = weekday)
E = [num, I];
E(E(:,22) == 0, :) = []; % Weekend bin, site 0
Y = [num, I];
Y(Y(:,22) == 1, :) = []; % Weekday bin, site 0
but I realized that that didn't help me with the raw data. So I want to do something similar to the raw data so I can then have two subsets of cell arrays (Weekend and weekday) but I can't figure it out.
I tried:
E = [raw, I];
E(E(:,24) == 0, :) = [];
.
.
.
but it does not like the concatenating attempt. So I tried making the logical a cell but it does not like that either.
Any help would be stellar, thank you!
0 commentaires
Réponse acceptée
OCDER
le 18 Juil 2018
[Num, ~, Raw] = xlsread('yourdata.xlsx');
I = Num(:,20) == 1 | Num(:,20) == 7; %Your logical index of weekends
Weekend = Raw( I, :);
Weekday = Raw(~I, :);
3 commentaires
Plus de réponses (1)
dpb
le 18 Juil 2018
With what you've got, you're just looking for
raw(I,:)=[];
to leave week weekday rows of all the data.
Knowing the actual data format in the raw array it might be possible to simplify the machinations done to have gotten to your I
2 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!