Finding series/pattern in an array
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
KALYAN ACHARJYA
il 13 Nov 2019
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
il 13 Nov 2019
Modificato: Daniel M
il 13 Nov 2019
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.
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!