作者warex14 (航)
看板MATLAB
标题[讨论] intersect 找不到共同元素
时间Thu Mar 12 16:30:25 2015
用了intersect 之後发现有个奇怪的地方
First是一个从Excel读入的文字阵列
MinVec亦同,但内容与长度阶与First不同
比较有问题的是First的74个元素
我从Excel档看到的是该元素确实也在MinVec里
但输入程式码:
[a IndexA IndexB]=intersect(First, MinVec); % a=First(IndexA)
h=intersect(IndexA,74) %IndexA若有74,h回传74
h=
Empty matrix: 0-by-1
觉得奇怪
把First弄短一点:
[a IndexA IndexB]=intersect(First(1:74), MinVec);
h=intersect(IndexA,74)
h=
74
竟然就有了,那为何整个First丢进去找不到阿?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.112.108.38
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MATLAB/M.1426149027.A.5CC.html
1F:推 shane: 一个是value一个是index 03/16 00:13
对,但是如果有共同元素的话,IndexA里要有74才对。
後来实际测试之後,发现是我的版本较旧的关系。
别的学校的同学有较新版本(2013),好像就找得到了。
※ 编辑: warex14 (140.112.25.106), 03/17/2015 10:14:31