Setdiff n intersect question
显示 更早的评论
Hi,
I have two dataset.
1)
- Shop# - floor#
- 321 - 4
- 321 - 2
- 321 - 3
- 322 - 0
- 322 - 2
2)
- shop# - floor#
- 322 - 1
- 322 - 0
- 322 - 2
if i do intersect of those two, i expect following, but i get just first row. WHy? 3)
- shop# - floor#
- 322 - 0
- 322 - 2
采纳的回答
>> a=[321 4;321 2;321 3;322 0;322 2];
>> b=[322 1;322 0;322 2];
>> intersect(a, b, 'rows')
ans =
322 0
322 2
8 个评论
With 'rows' i get following error
Error using getvarindices (line 25) Unrecognized variable name 'rows'.
Error in dataset/intersect (line 47) avars = getvarindices(a,vars,false);
Check for typos, e.g., not enclosing 'rows' in quotes. You should be able to verify by direct copy/paste that Guillaume's code works as shown.
i did. Something is wrong with 322, 2 entry. When i type the set in from commandline, it works with 'rows'. When i convert my program data into double and try it with 'rows' it returns only '322, 0' and not the second line ..:(
Can you paste your program here, then?
Otherwise, it's difficult to say what's wrong with it.
yes i understand....but i think i figured. My format was set to shortG so one 2 is 2.995 and the other is 2 i will make take the 'floor' n see if that helps if it does not, i will paste the code
ok, so i had to round floor number to get it to work... thanks.
@Neesha, if you got it work, you should accept Guillaume's answer

i accepted it, but i did not end up using 'rows', it worked without it as problem was coming from somewhere else
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Numeric Types 的更多信息
标签
另请参阅
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
