Repeated event in a array
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi there, I have a vector of size 10,000,000 x 1. The vector has inputs of 1 0 and -1 only. I want to find repeated events.
For instance 1 1 0 1 1 -1 -1 1 , I want to test if this exact same elements have appeared again in the data.
If so I would like a graph to represent the whole data plus the pattern in a colour.
Looking forward to a answer. Thanks.
댓글 수: 2
Jan
2012년 5월 4일
The question is not clear.
Your input is in = [1 1 0 1 1 -1 -1 1];
What is the wanted output? What are "repeated events"? What kind of graph do you want? For a suggestion how to draw a pattern in color, we have to knwo, what a "pattern" is in your case.
채택된 답변
Daniel Shub
2012년 5월 4일
Processing your example
A = [1 0 1 0 1 1 1 -1 -1 1 0 1 0 1 0 -1 -1];
x = [1 0 1 0];
with Loren's method would give
[1 10 12]
This can then be plotted with
stem(A);
hold on;
arrayfun(@(n)stem((0:3)+n, A((0:3)+n),'r'), [1, 10, 12]);
추가 답변 (1개)
Jan
2012년 5월 4일
Are you looking for neighboring elements with equal values? Then use diff. Are you looking for a specific patter, use strfind(data, [1 1 0 1 1 -1 -1 1]).
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!