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!