The problem seems to mainly be on line 46 because comparing two cell arrays is not supported in strcmpi. I believe there is a simple fix: Use ismember instead of strcmpi (and add lower so it's still case insensitive):
varToMatchA_idx=find(ismember(lower(obj.demoTable.Properties.VariableNames),lower(obj.varToMatch)));
This fix requires two additional changes.
On line 59, capture the case where obj.varToMatch is a cell containing only one column name:
if ~iscell(obj.varToMatch) || length(obj.varToMatch)==1
On line 76 expand the obj.varToMatch cell array. (Lines 59 and 72 already require that obj.varToMatch is a cell array already to reach this point).
T = cell2table(data(i).demographics(obj.varToMatch{:}),'VariableNames',varToMatchA);
Commit #https://github.com/huppertt/nirs-toolbox/commit/bd7206038069c8888eaf721ab2800f70720851c5 to automatically fill varToMatch in +nirs/+modules/AddDemographics.m seems to have broken support for cases where
length(obj.varToMatch)>1
.The problem seems to mainly be on line 46 because comparing two cell arrays is not supported in
strcmpi
. I believe there is a simple fix: Useismember
instead ofstrcmpi
(and addlower
so it's still case insensitive):varToMatchA_idx=find(ismember(lower(obj.demoTable.Properties.VariableNames),lower(obj.varToMatch)));
This fix requires two additional changes.
obj.varToMatch
is a cell containing only one column name:if ~iscell(obj.varToMatch) || length(obj.varToMatch)==1
obj.varToMatch
cell array. (Lines 59 and 72 already require thatobj.varToMatch
is a cell array already to reach this point).T = cell2table(data(i).demographics(obj.varToMatch{:}),'VariableNames',varToMatchA);