Info
此问题已关闭。 请重新打开它进行编辑或回答。
using ismember or something else
1 次查看(过去 30 天)
显示 更早的评论
Hi All,
I have a dataset 'RestInfo' like this.
Name location startNum Q1Earning Q2Earning Restaurant1 South second 10 7.9 Restaurant2 West first 11 17.39 nameHolder2 unknown notOpen 0 0 Restaurant1_Annex West first 11 13.34 Restaurant3 EastSide third 8.3 7.1 nameHolder1 unknown notOpen 0 0
I have global variable 'gNames' 1x2 cell gNames = 'Restaurant1' 'Restaurant2' 'Restaurant3'
now from 'RestInfo' I just want to get rows which has names matching with in gNames, and also those which has starting name matching , so that in new dataset I get following
Name location startNum Q1Earning Q2Earning Restaurant1 South second 10 7.9 Restaurant2 West first 11 17.39 Restaurant1_Annex West first 11 13.34 Restaurant3 EastSide third 8.3 7.1
I was able to ismember as follow but then it does not get me Restaurant1_Annex.
newInfo = RestInfo(ismember(RestInfo.Name, gNames),:);
What should I do so that Restaurant1_Annex is not missing from my final newInfo dataset?
0 个评论
回答(1 个)
Star Strider
2015-5-7
Instead of the ismember function I would use the setdiff function.
2 个评论
Image Analyst
2015-5-7
编辑:Image Analyst
2015-5-7
What about strfind()? And how about spelling Restaurant consistently?
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!