Borrar filtros
Borrar filtros

How to get the logical index 1 if the cell is missing?

2 visualizaciones (últimos 30 días)
Smithy
Smithy el 21 de Oct. de 2022
Editada: Stephen23 el 3 de En. de 2023
Hello everybody,
I have the 2x1 cell array and (2,1) is {1×1 missing}.
To get the logical index 1 about data(2,1) missing, I tried
ismissing, isempty, and contains functions but all does not work...
Please let me know how to get the logical index 1 about the cell(2,1) is missing?
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
load input.mat
% I tried below but all does not work
ismissing(data(2,1))
isempty(data(2,1))
contains(data(2,1),'missing')
% to get the logical index 1 about data(2,1) missing, how to do it...

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Oct. de 2022
Editada: Walter Roberson el 21 de Oct. de 2022
cellfun(@(M) any(ismissing(M)), data)
or if you just want to test the one,
any(ismissing(data{2,1}))
Note that missing is a value that can appear as entries in arrays, so it is possible for an array to have some missing entries and some non-missing entries. The above code checks for cells in which at least one entry is missing, but does not report which of the array elements are missing.
  1 comentario
Smithy
Smithy el 21 de Oct. de 2022
Editada: Stephen23 el 3 de En. de 2023
Wow... It works perfectly. Thank you very much. I really appreciate with it.

Iniciar sesión para comentar.

Más respuestas (1)

David Hill
David Hill el 21 de Oct. de 2022
load input.mat
ismissing(data{2})
ans = logical
1
  1 comentario
Smithy
Smithy el 21 de Oct. de 2022
Thank you very much for your huge help. It works really well.

Iniciar sesión para comentar.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by