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

조회 수: 2 (최근 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.

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

채택된 답변

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 CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by