I have 2 cellArray which changes double to string. I wanna compare these 2 cellArray whether they are same or not.

1 回表示 (過去 30 日間)
%for example;
%situation 1
cellArray=[p.1,p.2,p.3] %cell
cellArray2=[p.1,p.2,p.3] %cell
situation 2
cellArray=[1,2,3] %double
cellArray2=[1,2,3]
% what kind of code I need to compare these cellArray to each other while they are cell or double?
  3 件のコメント
Jan
Jan 2013 年 7 月 9 日
[1,2,3] is not a cell array. Please clarify this contradiction.
sermet
sermet 2013 年 7 月 9 日
(p.1 p.2 p.3) char
[1 2 3] double

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

採用された回答

Friedrich
Friedrich 2013 年 7 月 9 日
編集済み: Friedrich 2013 年 7 月 9 日
Hi,
in your case (double array or cell which contains char data) an isqual is enough:
% cellArray=[1,2,3] %double
% cellArray2=[1,2,3] %double
cellArray={'a','b','c'}; %cell
cellArray2={'a','b','c'}; %cell
isequal(cellArray,cellArray2)
Edited after that comment from Jan
  1 件のコメント
Jan
Jan 2013 年 7 月 9 日
"isequal()" is enough for the cell array inputs also, so there is no reason to step into the cell elements by cellfun.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by