Hello all,
I have a function where I am passing three different behaviors (drug, before drug, after drug).
function defining_parsing(subj, path, data_type, behavior)
all_folders = dir(fullfile(path, subj, '/dir/'));
expression_behavior = [data_type, '.*', '(s2|s4|s6|s3)', '.*'];
elseif behavior == 'before drug'
expression_behavior = [data_type, '.*', '(w3|w2|w4|w|WA)', '.*'];
elseif behavior == 'after drug'
expression_behavior = [data_type, '.*', '(EO)', '.*'];
When I pass the variable outside of the function for the above I get the following error:
Arrays have incompatible sizes for this operation.
Error in defining_parsing (line 20)
When I pass the the variable for behavior within the function, I do not get the error:
function defining_parsing(subj, path, data_type, roi, behavior)
all_folders = dir(fullfile(path, subj, '/dir/'));
expression_behavior = [data_type, '.*', '(s2|s4|)', '.*'];
elseif behavior == 'before drug'
expression_behavior = [data_type, '.*', '(w3|w2|)', '.*'];
elseif behavior == 'after drug'
expression_behavior = [data_type, '.*', '(EO)', '.*'];
I have tried the following:
1) making sure that both the variable input to the function and the variable input with the function are the same (they are both char)
behavior = num2str(behavior);
2) making sure that there are no typos.
Do you have any suggestions? Thanks so much!