Finding series/pattern in an array

조회 수: 4 (최근 30일)
Niravkumar Ambaliya
Niravkumar Ambaliya 2019년 11월 13일
댓글: Niravkumar Ambaliya 2019년 11월 13일
I have a large vector, for example, A = [0 0 0 1 3 6 9 10 10 10 10 10 0 0 0 0 2 4 6 9 10 10 10 10 0 ....... ]
I want to find out signal rise time for each rise, for example in this case signal going from 0 to 10. Also after signal has reached 10, how long does it stays at 10.
This sequence of rise and steady-state can be multiple time in an array.
Note: Each sample(datapoint) is 10 msec apart
Rise_Time.PNG
.

답변 (2개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 11월 13일
I have answered this question with help of @Jan Answer's here
A =[0 0 0 1 3 6 9 10 10 10 10 10 0 0];
d=[true,diff(A)~=0,true];
n=diff(find(d)) % Thes Gives the Time sequence
t=10:10:length(A)*10;
plot(t,A); % Get Hints
ylim([-5 12]); % Lim on y axes
From the n value, which gives the repeatation of A, you can multiply by 10 and plot are per your requirements.
245.png
  댓글 수: 1
Niravkumar Ambaliya
Niravkumar Ambaliya 2019년 11월 13일
Thanks for the answer. But I don't want to plot the signal. I want to know how many cycles (Rise-Steady State-Fall) are there in an array. Additionally, for each cycle what is the rise time (time taken from 0 to 10. And once signal reached 10, for how long does it stay there.
A = [0 0 0 1 3 6 9 10 10 10 10 10 0 0 0 0 2 3 4 6 7 9 10 10 10 10 0];
Output expected:
Number of cycles: 2
1st cycle rise time = 5 samples*10 = 50 msec;
1st cycle steady time = 4 samples*10 = 40 msec;
2nd cycle rise time = 7 samples*10 = 70 msec;
3rd cycle steady time = 3 samples*10 = 30 msec;

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


Daniel M
Daniel M 2019년 11월 13일
편집: Daniel M 2019년 11월 13일
If you have the signal processing toolbox you can do this pretty easily using the functions risetime and pulsewidth. You just have to play with the settings. Typically rise time is characterized by the time between the bottom 10% and upper 90% of your signal, and this is the default of risetime, but here I show you how you can obtain it for the very bottom and very top.
A = [0 0 0 1 3 6 9 10 10 10 10 10 0 0 0 0 2 4 6 9 10 10 10 10 0];
% get the rise time
% can't use [0 100] because it requires a tolerance level
% but since your signal is bounded by 0 and 10 with no noise, a very low tolerance works
% But we will have to round the output up.
risetime(A,1,'PercentReferenceLevels',[0.1 99.9],'Tolerance',0.01)
% ans =
% 4.8802 4.9102
And wrap that function call in ceil() will return 5 and 5. See the attached figure.
For the pulsewidth, use
pulsewidth(A,1,'MidPercentReferenceLevel',99.98,'Tolerance',0.01)
% ans =
% 4.0572 3.0572
In this case, use floor() to round the answer down to 4 and 3.
  댓글 수: 1
Niravkumar Ambaliya
Niravkumar Ambaliya 2019년 11월 13일
Unfortunately I do not have signal processing toolbox. Is there a way without signal processing toolbox?

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

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by