check a null value

39 ビュー (過去 30 日間)
Amish
Amish 2013 年 4 月 15 日
I want to check in a cell array that at which position or which element is null or string how to do that for example i have array named att={'strong',[],'wind',[],'overcast','weak',[]}; now in this array i want to apply a if condition that if (att(x,y) contain null element) do this else ---. how to do that how to check null values and string values separately. i am using is empty but it always give either 1 or either 0. it is unable to recognize the null values in att variable.
  1 件のコメント
Jan
Jan 2013 年 4 月 15 日
I do not see "null values" in you cell. Do you mean the empty matrices?
It would be helpful, if you post the code, instead of the vague explanation "I am using is empty". How could we guess what's going wrong without seeing any details? Please note that 0 and 1 are the expected answers for the isempty() command.

サインインしてコメントする。

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 4 月 15 日
編集済み: Andrei Bobrov 2013 年 4 月 15 日
att={'strong',[],'wind',[],'overcast','weak',[]};
t = cellfun('isempty',att);
example
a1 = att;
a1(t) = {0};
  2 件のコメント
Jan
Jan 2013 年 4 月 15 日
As usualy I mention, that cellfun('isempty', att) is more efficient.
Andrei Bobrov
Andrei Bobrov 2013 年 4 月 15 日
OK, corrected.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by