This can be done using strcmp
or similar functions to do the string matching across your cell array, then using sum
to look for the first column with all zeros (no hits) if any.
c= 1; % which column do we want
sArray = Tickerarray(:, c:End);
l = size(sArray,1); % how many rows
% preallocating output array
out = ones(l,1).*size(sArray,2);
for n = 1:l
str = sArray{n,1};
x = strcmp(str, sArray); % is logical index of hits
m = find(sum(x)==0,1); % find first column containing all zeros
if ~isempty(m) % else defaults to preallocated value
out(n) = m-1;
end
end