pattern search help in sample

조회 수: 1 (최근 30일)
FRANCISCO
FRANCISCO 2013년 10월 19일
답변: Image Analyst 2013년 10월 19일
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
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
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)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by