TIME COUNTER IN MATLAB

2 vues (au cours des 30 derniers jours)
andrei_Dex
andrei_Dex le 4 Juil 2013
Hello! I want to implement a time counter in Matlab and I can't succed. I want for the output to be one only when the input signal is above 1 for more than 2 second. In all other cases the output should be zero. How can i do that?

Réponses (1)

Image Analyst
Image Analyst le 4 Juil 2013
You can threshold your signal:
above1 = yourSignal > 1;
Now you'll have a lot of true and false sections depending on whether your signal is above or below 1, respectively. Now, if you have the Image Processing Toolbox (IPT), you're in luck, you just do
measurements = regionprops(above1, 'Area');
allLengths = [measurements.Area];
Then you need to know how many elements correspond to a time of 2 seconds, and filter those out with ismember(). Not hard (just 2 or 3 lines), but let me know if you have that toolbox first, and if you can't figure it out, I'll let you know, or look in my Image Segmentation Tutorial.
Otherwise, without the IPT you can do it but it's tricky. It's been given in the Answers forum before but I don't remember the steps (because I have the IPT and don't have to).

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by