필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Smithy
Smithy 2022년 10월 21일
편집: Stephen23 2023년 1월 3일
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...

채택된 답변

Walter Roberson
Walter Roberson 2022년 10월 21일
편집: Walter Roberson 2022년 10월 21일
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
Smithy
Smithy 2022년 10월 21일
편집: Stephen23 2023년 1월 3일
Wow... It works perfectly. Thank you very much. I really appreciate with it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

David Hill
David Hill 2022년 10월 21일
load input.mat
ismissing(data{2})
ans = logical
1
  댓글 수: 1
Smithy
Smithy 2022년 10월 21일
Thank you very much for your huge help. It works really well.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by