필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

using ismember or something else

조회 수: 2 (최근 30일)
Neesha
Neesha 2015년 5월 7일
마감: MATLAB Answer Bot 2021년 8월 20일

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?

답변 (1개)

Star Strider
Star Strider 2015년 5월 7일
Instead of the ismember function I would use the setdiff function.
  댓글 수: 2
Image Analyst
Image Analyst 2015년 5월 7일
편집: Image Analyst 2015년 5월 7일
What about strfind()? And how about spelling Restaurant consistently?
Neesha
Neesha 2015년 5월 8일
Yes I do have fat finger .....sorry about the spelling, yes it is consistent in my dataset.
I know strfind, but I do not know how to apply to the entire dataset.

이 질문은 마감되었습니다.

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by