pattern search help in sample
조회 수: 1 (최근 30일)
이전 댓글 표시
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
dpb
2013년 10월 19일
How are the data stored?
But, the general idea would likely come from
doc ismember
but will wait to find out about the form...
답변 (1개)
Image Analyst
2013년 10월 19일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!