MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   识别单元格阵列中的唯一性 (https://www.labfans.com/bbs/showthread.php?t=23183)

poster 2019-12-10 20:30

识别单元格阵列中的唯一性
 
我在[URL="http://en.wikipedia.org/wiki/MATLAB"]MATLAB中[/URL]有一个45x2的单元格,第一列是任意大小的双精度矩阵。

其中一些矩阵是重复的,而其他则不重复。我试图仅去除唯一的矩阵(但记录重复的次数),并保持第二列不变。

我已经尝试了许多方法(制表,历史等),但是由于细胞结构(我认为),它们都失败了。如果不逐一遍历每个人,该如何去做呢?



[B]回答:[/B]

如果将矩阵转换为字符串,则可以在它们上运行唯一的:

%# create a sample cell array mc = {magic(3);magic(4);magic(4);magic(5);magic(3);magic(4)} %# convert to strings mcs = cellfun(@(x)(mat2str(x)),mc,'uniformoutput',false); %# run unique [uniqueCells,idxOfUnique,idxYouWant] = unique(mcs);

[url=https://stackoverflow.com/questions/2392256]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 05:09

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.