MATLAB: Counting a pattern frequency in a column

countingmatching

Hi
I am trying to count the of a pattern called "MyNode={'28'}" as shown in the code below.
clc; clear;
MyNode={'28'};
MyNode_Decimal=str2double(MyNode);
MyNode_Hex=lower(arrayfun(@(x) (dec2hex(x)), MyNode_Decimal, 'UniformOutput', false));
PatternL2={'00:00:00_00:00:'};
MyNode_L2=strcat(PatternL2,MyNode_Hex);
[~,~,raw]= xlsread('test.xlsx');
Col3= cellfun(@num2str,raw(:,3),'uni',0);
Col3_final=Col3(2:end);
cond1=strfind(Col3_final,MyNode_L2);
The corresponding string is "00:00:00_00:00:1c (00:00:00:00:00:1c) (TA)". I want to count the red colored pattern, not including the blue pattern. I used ismember, strcmp but no use, the closest is strfind but I don't get it exactly.
I really appreciate your help.
NL

Best Answer

The code below will count the number of times that the pattern you describe is found in the third row of the Excel file.
MyNode={'28'};
MyNode_Decimal=str2double(MyNode);
pattern=sprintf('00:00:00_00:00:%x (00:00:00:00:00:%x) (TA)',...
MyNode_Decimal,MyNode_Decimal);
[~,~,raw]= xlsread('test.xlsx');
L=ismember(raw(:,3),pattern);
%postions=find(L);
N_found=sum(L);