If you just want to aggregate into one value, you can say this:
C9=any((cellfun(@(n) ~isempty(n), strfind(data4, A9{1}))));
The any
function returns true if any of the values in the input array is not zero.
For the second question, if you used any
, the result is boolean value (true or false), then you can just do a logical AND.
C9=any((cellfun(@(n) ~isempty(n), strfind(data4, A9{1})))) && any((cellfun(@(n) ~isempty(n), strfind(data4, D9{1}))));
However, I'm not sure what your data file is and what you are trying to say. The importdata
function most often returns a structure with multiple fields, and the strfind
function operates on either a string or a cell array of strings, but not structures. So the reason you get a vector as output puzzles me. It might help if you describe your input data.