mercredi 28 décembre 2016

finding the number of occurrence of a pattern within a cell in matlab?

i have a cell like this:

x = {'3D'
    'B4'
    'EF'
    'D8'
    'E7'
    '6C'
    '33'
    '37'} 

let's assume that the cell is 1000x1. i want to find the number of occurrence of pattern = [30;30;64;63] within this cell but as the order shown. in the other word it's first check x{1,1},x{2,1},x{3,1},x{4,1} then check x{2,1},x{3,1},x{4,1},x{5,1} and like this till the end of the cell and return the number of occurrence of it.

Here is my code but it didn't work!

while (size (pattern)< size(x))
    count = 0;
    for i=1:size(x)-length(pattern)+1
        if size(abs(x(i:i+size(pattern)-1)-x))==0
            count = count+1;
        end
    end
end

Thanks!

Aucun commentaire:

Enregistrer un commentaire