# Recognise specific pattern in timetable

조회 수: 1 (최근 30일)
Mads Petersen . 2022년 5월 9일
답변: Mads Petersen . 2022년 7월 9일
I have a timetable logfile from an electrical motor.
This motor runs a variable rounds per minute, according to manual adjustment.
if i plot the entire timeline vs rpm i get what like in attached picture "1".
The intresting part of that data is where you see the rpm drops from ~2250 rpm to ~1300rpm. please see picture "2".
Is it possible to make a code that is recognising this specific pattern automatically, and isolate the time where this is happening? in this case it must be isolated from ~60s to ~100s to isolate this specifik range.
Thanks!
##### 댓글 수: 2없음 표시없음 숨기기
Star Strider 2022년 5월 9일
The findsignal function is the only method that I am aware of that would easily do this sort of pattern-matching.
Thank you that is a very cool function i did not know. Do you have experience with it? got some pattern recognition, but a lot of failures also. I dont think the matlab documentation i explaining clear enough what the different steps do.
i made a vector that look a lot like the pattern i am intrested in. see image3 got pattern script setup to find pattern in data. see here: looks promising, but is finding more pattern than it should. following matlab documentation more. looks better i still have a lot of errors. Specially when finding pattern of different log files, where typical the time and lograte (hz) is changed. Rpm pattern starting from ~2200 and down to ~1400 is always the same. see code:
subplot(2,1,1)
plot(data)
title('Data')
subplot(2,1,2)
plot(signal)
title('Signal')
figure
findsignal(data,signal)
dt = data;
dt(t>24&t<25) = 1900;
dt(t>25&t<26) = 800;
findsignal(dt,signal,'Metric','absolute')
findsignal(dt,signal,'TimeAlignment','dtw','Metric','absolute') %Let the x-axes stretch if the stretching results in a smaller absolute distance between the closest data segment and the signal.
dt(t>0&t<0.1) = 2400;
dt(t>0.1&t<0.12) = 1900;
Can yo explain more on how this is working?

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

### 답변 (3개)

Mitch Lautigar 2022년 5월 10일
After you grab the data, run a simple check to see if the rpm's drastically decrease. This can look something like the following
%rpms_val is the name i'm use for your "y" data points.
%rpms_time is the name i'm going to use for your "x" data points.
rpms_slope = [];
for i = 1:length(rpms_val)-1
rpms_slope(i) = (rpms_val(i+1) - rpms_val(i)) / (rpms_time(i+1)-rpms_time(i));
end
rpms_check = find(rpms_slope < -5) %-5 can be whatever tolerance you want.
from here, you can code in any flags you wish. You can even change the color of the data that is negative.
##### 댓글 수: 2없음 표시없음 숨기기
Thank you for comment. I keep getting this error using you script. am i missing something?
rpms_val = 12×1
103 ×
1.6937
2.1374
2.1364
2.0351
1.8646
1.6375
2.2471
0.8924
0.8503
0.8445
rpms_time = 12×1 duration
0 sec
4 sec
8 sec
12 sec
16 sec
20 sec
24 sec
28 sec
32 sec
36 sec
%rpms_val is the name i'm use for your "y" data points.
%rpms_time is the name i'm going to use for your "x" data points.
rpms_slope = []
for i = 1:length(rpms_val)-1
rpms_slope(i) = (rpms_val(i+1) - rpms_val(i)) / (rpms_time(i+1)-rpms_time(i))
end
rpms_check = find(rpms_slope < -5) %-5 can be whatever tolerance you want.
The denominator in matrix division for duration arrays must be a real scalar double value.
Mitch Lautigar 2022년 5월 16일
rpms_slope(i) = (rpms_val(i+1) - rpms_val(i)) ./ (rpms_time(i+1)-rpms_time(i))
forgot it was vector math. Should fix your issue.

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

Les Beckham 2022년 5월 10일
편집: Les Beckham 님. 2022년 5월 10일
One approach without requiring the Signal Processing Toolbox:
x = data(:,1);
y = data(:,2);
startidx = find(y>2000, 1, 'first'); % you may need to adjust this
% The following line may also need to be adjusted if the desired region is
% not strictly decreasing
stopidx = find(diff(y(startidx:end))>1, 1, 'first') + startidx - 1
stopidx = 26
plot(x,y)
hold on;
plot(x(startidx:stopidx), y(startidx:stopidx), 'r.') ##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

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

Thank you very much for all the nice answers. All of them are very intresting. i went with the diff. solution which i simple and works for now.
I thnik the findsignal is more intresting but required more fine tuning.
Thanks everyone

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

### 카테고리

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

### Community Treasure Hunt

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

Start Hunting!