Unique elements in cell array

버전 1.0.0.0 (1.4 KB) 작성자: Patrick Mineault
unique for numeric cell arrays. If c = {[0],[1,2],[0],[8],[1,2]} returns {[0],[1,2],[8]}
다운로드 수: 2K
업데이트 날짜: 2011/6/8

라이선스 보기

function [Au, idx, idx2] = uniquecell(A)

Same as built-in unique, but works for cell arrays where each element is a numeric array.

For A a cell array of matrices (or vectors), returns Au, which contains the unique matrices in A, idx, which contains the indices of the last appearance of each such unique matrix, and idx2, which contains th indices such that Au(idx2) == A

Example usage:

A = {[1,2,3],[0],[2,3,4],[2,3,1],[1,2,3],[0]};
[Au,idx,idx2] = uniquecell(A);

Results in:

idx = [6,5,4,3]
Au = {[0],[1,2,3],[2,3,1],[2,3,4]}
idx2 = [2,1,4,3,2,1]

Algorithm: uses cellfun to translate numeric matrices into strings then calls unique on cell array of strings and reconstructs the initial matrices.

인용 양식

Patrick Mineault (2026). Unique elements in cell array (https://kr.mathworks.com/matlabcentral/fileexchange/31718-unique-elements-in-cell-array), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2008b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Characters and Strings에 대해 자세히 알아보기
도움

도움 준 파일: uniqueCellGeneralized(A), uniqueCells

버전 게시됨 릴리스 정보
1.0.0.0