Prev: how to set properties of java uicontrols
Next: histc
From: arielon dada on 16 Jan 2010 17:15 Hello I am looking for an easy way to compare two cells of strings. for example a={'aa','ba','c'} b={'c','ba','dd'} and I want the function(a,b) to return someting like [0,1,0] as the first and the third strings of the first cell don't exist in the second. the function strcmp() minds the order which is not suitable for my needs Thank you for any comments
From: Matt Fig on 16 Jan 2010 17:22 One approach TF = cellfun(@isequal,a,b)
From: Matt Fig on 16 Jan 2010 17:29 "arielon dada" <ariel_gold(a)walla.com> wrote in message <hitdpp$395$1(a)fred.mathworks.com>... > Hello > I am looking for an easy way to compare two cells of strings. for example > a={'aa','ba','c'} > b={'c','ba','dd'} > and I want the function(a,b) to return someting like [0,1,0] as the first and the third strings of the first cell don't exist in the second. the function strcmp() minds the order which is not suitable for my needs > > Thank you for any comments I may have misunderstood your request, in part because ONLY the first string of the first cell doesn't exist in the second cell. Will ISMEMBER work for your needs?
From: arielon dada on 17 Jan 2010 01:37 "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hite6c$re9$1(a)fred.mathworks.com>... > One approach > > > TF = cellfun(@isequal,a,b) Thank you, the function you added indeed works. I had two problems though. a. what I ment to write is that the output will be [0,1,1] as only the first string in a doesn't appear in b (my mistake of coutse). b. the cells I work with are from xlsread. I assumed that they are ordinary cells but it seem that they are not. thank you very much
From: arielon dada on 17 Jan 2010 01:40
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hitejg$n3j$1(a)fred.mathworks.com>... > "arielon dada" <ariel_gold(a)walla.com> wrote in message <hitdpp$395$1(a)fred.mathworks.com>... > > Hello > > I am looking for an easy way to compare two cells of strings. for example > > a={'aa','ba','c'} > > b={'c','ba','dd'} > > and I want the function(a,b) to return someting like [0,1,0] as the first and the third strings of the first cell don't exist in the second. the function strcmp() minds the order which is not suitable for my needs > > > > Thank you for any comments > > I may have misunderstood your request, in part because ONLY the first string of the first cell doesn't exist in the second cell. Will ISMEMBER work for your needs? thank you very much. ismember should have worked, but it seem that it doesn't work, for cell imported from xls. a=readxls(filename.xls) ismember(a(1,:),a(2,:)) return a bunch of errors thank you very much |