pattern search help in sample
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
dpb
el 19 de Oct. de 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...
Respuestas (1)
Image Analyst
el 19 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Histograms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!