필터 지우기
필터 지우기

How to detect repetition in data?

조회 수: 9 (최근 30일)
Jacqueline
Jacqueline 2013년 7월 2일
Hello,
So I have various data files containing different information, such as engine speed, engine torque, etc. Each file has about 10,000 points, one for each second (so the data was gathered for over two hours). I'm trying to analyze the data such that if for 60 seconds, the data is the same, then there is an error with the data. For example, if the engine speed was 79.356 for 60 data points, there is an error..
How do I go about doing this?

채택된 답변

Evan
Evan 2013년 7월 2일
편집: Evan 2013년 7월 2일
Do you only want to identify adjacent points of repitition for your data, or any points that are not unique? If you're wanting the former, you could try loading in the data into a numerical matrix and using the "diff" command across your vector. Any point where the difference is zero would be a repeated value. In this way you could determine the beginning, extent, etc. of data reptition for whatever conditions you need to meet to throw an error.
Example:
data = 100*rand(1,10000); %random dataset
data(1,50:120) = 79.356; %set some data to constant value
datarep = ~diff(data);
Now, you can count the run-length of each set of repeated data. There might be other ways of doing it, but for run lengths I often convert to a string and use "regexp."
s = regexprep(num2str(datarep),' ',''); %convert to string, remove spaces
[ids runs] = regexp(s,'1+','start','match');
l = cellfun('length',runs);
In this way, ids will tell you where each set of repeated values starts, and l will tell you the length of each. This will give you enough information for seeing if your error conditions are met.
  댓글 수: 1
Jacqueline
Jacqueline 2013년 7월 3일
I kind of get what you're doing. I understand the diff function, but you lost me with the rest. When I use the diff function on a variable, it gives me a long list of numbers. I want to know if/where there are 60 zeros in a row, because that is where the data has not changed for 60 seconds. How do I do that?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Kwen
Kwen 2013년 7월 2일
I would use a loop and the unique function.
I'm not sure you problem is consistent though-you can possibly have values that add above 60 even with the unique function but that would not necessarily cause an error?

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by