MATLAB: Problems with intersect and cellfun functions

intersect

I'm using the script below to try to find all the matches in a column of 2 excel files. The intersect function returns indices which are out of bounds for the first cell (patternsize is 41351 x 1, dataP is 2000 x 1). The first cell of "ic" is 41352, and for "id" it is 6001. The first cell of D is then blank. When I try to pass all of this on in the next line, everything blows up and I get the error 'Index exceeds matrix dimensions'. The script seemed to work fine with other files with different dimensions. I'm pretty much a novice with this, so any suggestions as to what is going wrong is greatly appreciated.
[numdataP,patternsizeP]=xlsread('state.xlsx');
[~,dataP]=xlsread('pinellas.xlsx');
[D,ic,id] = intersect(patternsizeP,dataP)
indexP=cellfun(@(x)find(ismember(dataP,x)==1),D,'uniformoutput',false)

Best Answer

>> [~,~,rawS] = xlsread('state.xlsx');
>> [~,~,rawP] = xlsread('pinellas.xlsx');
>> [idxP,idxS] = ismember(rawP(:,1),rawS(:,1));
>> out = rawS(idxS(idxP),[1,1,16]);
>> out(:,2) = rawP(idxP,2)
out =
'PIN159614' 'SOO' [271]
'PIN159614' 'SO1' [271]
'PIN159614' 'SOA' [271]
'PIN159614' 'SO0' [271]
'PIN159614' 'SO3' [271]
'PIN159614' 'SO2' [271]
'PIN159614' 'SO5' [271]
'PIN159614' 'SOE' [271]
'PIN159614' 'SOD' [271]
'PIN159614' 'SOG' [271]
'PIN159614' 'SO6' [271]
'PIN725789' 'SOA' [262]
'PIN725789' 'SOC' [262]
'PIN725789' 'SOB' [262]
'PIN725789' 'SOE' [262]
'PIN725789' 'SOD' [262]
'PIN725789' 'SOG' [262]
'PIN725789' 'SOL' [262]
'PIN725789' 'SOO' [262]
'PIN725789' 'SO1' [262]
'PIN725789' 'SO0' [262]
'PIN725789' 'SO3' [262]
'PIN725789' 'SO2' [262]
'PIN725789' 'SO5' [262]
'PIN725789' 'SO7' [262]
'PIN725789' 'SO6' [262]
'PIN725789' 'SO8' [262]