Find a row of repeated values?
이전 댓글 표시
Hi, first off I am very new to Matlab. I asked a similar question yesterday but I don't think I was specific enough so I'm going to try again...
I am analyzing data that comes from a truck, such as engine speed, vehicle speed, etc. The data is collected randomly throughout the day for about 3 hours (10,000 seconds). I am trying to write a script that will detect any repetition in the data that last for 60 seconds or more. Because if that happens, there is something wrong with the sensors in the truck.
For example, if for engine speed I had 10,000 points ranging from 0-2100, and for 60 seconds in a row the data was stuck on 1,000, how would I write a script to detect this and say there is an error?
I appreciate any help I can get! Thanks
채택된 답변
추가 답변 (1개)
Jacqueline
2013년 7월 8일
0 개 추천
댓글 수: 7
Since the data is a column vector rather than a row vector, regexp cannot operate on a character array created from it. Does the following change fix your problem?
[ids runs] = regexp(regexprep(num2str(~diff(data.')),' ',''),'1+','start','match');
The only change is the addition of the "transpose" (.') operator to turn your column vector into a row vector.
Jacqueline
2013년 7월 8일
Evan
2013년 7월 8일
You're welcome!
Jacqueline
2013년 7월 8일
Evan
2013년 7월 8일
So you're saying that, if at any point the truck's velocity is zero, you wont want to consider that datapoint for your repetition check? If so, you can just add another condition to the creation of your logical vector:
datarep = ~diff(data) & data(2:end) ~= 0;
All this modification does is say "if the difference in the data at each point is zero, and if the data at that point isn't itself zero, return true."
The reason that I index from the second datapoint to the end is because your difference array will be one element shorter than your data array.
Jacqueline
2013년 7월 8일
Jacqueline
2013년 7월 11일
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!