pattern search help in sample
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Let me explain the problem. I have a 5000 sample patterns of length 4 with the relative frequencies of each of them, for example:
[1 1 1 0] -------- 0,007
[0 1 0 0] -------- 0.012
[1 1 1 1] ------- 0,003
and so on until 5000
Performing a separate load, which for explaining this case and therefore influence not indicate, for example I get the pattern:
[0 1 0 0]
My question is this:
What code should I use to find this pattern in the sample of the 5000 data? I realize this because i want to know the relative frecuency automatically
thank you very much
1 Kommentar
dpb
am 19 Okt. 2013
How are the data stored?
But, the general idea would likely come from
doc ismember
but will wait to find out about the form...
Antworten (1)
Image Analyst
am 19 Okt. 2013
Try this:
% Create sample data in a rectangular numerical array.
m = [1 1 1 0
0 1 0 0
1 1 1 1]
% Create array for converting a row into unique numbers
% 0 - 15 based on the binary pattern in each row.
twos = repmat([8 4 2 1], [size(m, 1), 1]);
% Get a column vector of the number in each row.
numbers = sum(m.*twos, 2)
% Get the frequency of occurrence (histogram).
counts = histc(numbers, 0:15)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!