How to find the index of missing values in a cell array without looping through each element?
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Julia Smith
le 11 Juil 2022
Réponse apportée : Bharat Chandra Mukkavalli
le 11 Juil 2022
S1 = struct();
S2 = struct();
C = {S1 S2 missing};
0 commentaires
Réponse acceptée
Voss
le 11 Juil 2022
You can use cellfun to call ismissing on the contents of each cell:
S1 = struct();
S2 = struct();
C = {S1 S2 missing}
is_missing = cellfun(@ismissing,C)
idx_missing = find(is_missing)
(That's not got much loops.)
0 commentaires
Plus de réponses (1)
Bharat Chandra Mukkavalli
le 11 Juil 2022
Hi,
You can use the "cellfun()" function to apply a function to all the contents in a cell array. Further documentation on cellfun() can be found here: https://in.mathworks.com/help/matlab/ref/cellfun.html
Refer to link here on finding the indices of non-empty cells in a cell array: https://in.mathworks.com/matlabcentral/answers/42283-index-non-empty-cells-in-cell-array
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!