How to determine if an entry is cell type or others?

조회 수: 1 (최근 30일)
J. Hu
J. Hu 2013년 10월 1일
답변: the cyclist 2013년 10월 1일
I wanted to have a function to remove the empty cell, Null cell, NaN in a vector:
A = [2 NaN 3] % DatawEmpty example
B = {'a' '' [] 'b'} % DatawEmpty example
what I tried to do is have a loop in which I make a judgement for each entry using following code:
judge1 = isempty(DatawEmpty{ix});
judge2 = isnan(DatawEmpty{ix});
judge3 = strcmp(DatawEmpty{ix},'null');
if judge1 + judge2 + judge3 ~=0, then the entry will be removed from the vector. However, as you can see isempty/isnan/{} does not apply to vector composed of all types of data. So the code does not work for all.
So I wanted to use a judge to know the data type first. Is there any way to know that? like iscell? Thanks...

채택된 답변

the cyclist
the cyclist 2013년 10월 1일
You can use the class() function to determine the class of an object.
>> doc class
for details.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by