unique values in cell array

조회 수: 37 (최근 30일)
Franco
Franco 2013년 9월 27일
답변: Wayne King 2013년 9월 27일
I have a cell array with both numerical values and strings
test1 = {1,2,3,'No';1,3,2,'Yes';2,2,2,'Yes'}
I need to find the unique values of each column, regardless of the data type. Anyone know how to do this? Thanks.

답변 (1개)

Wayne King
Wayne King 2013년 9월 27일
You could do this:
test1 = {1,2,3,'No';1,3,2,'Yes';2,2,2,'Yes'};
out = unique(cellfun(@num2str,test1,'uni',0));
and then convert the strings with numbers back to numbers.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by