I have a data which is 20*55 cell
and I want to search for a word in this cells
I search in column 51,52,53,54 & 55(which contain text)
so i have to repeat by search five times each in a column
I use this code:
[ndata text alldata] = xlsread('categ.xlsx','new');j=1;k=1;D=alldata(:,51); % search in column 51
for H = 1:R % for loop to remove NaN
if isnan(D{H}) D{H} = ''; endendfor E=1:R % from 1 : length of columns
B=~cellfun('isempty',regexp(D,'BATTERY')) ; % works well search for battery (uppercase) and returns 1 or 0
if (B(E) == 1) % if value of array greater than or equal 1
Defs(j)=E; % save its postion (E,1)
j=j+1; else % save all arrays didn't have 'check' separately
not(k)=E; k=k+1; endend data=alldata(Defs,:); % show data contains 'battery'
I want to use or ( if the word is exist in 51 or 52 ….55) , to reduce time
HOW I CAN SEARCH IN THE FIVE COLUMNS AT ONCE?
Best Answer