Finding series/pattern in an array
조회 수: 2 (최근 30일)
이전 댓글 표시
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
.
댓글 수: 0
답변 (2개)
KALYAN ACHARJYA
2019년 11월 13일
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.
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!