필터 지우기
필터 지우기

Calculate high and low length of given square wave?

조회 수: 4 (최근 30일)
MoeIsKing
MoeIsKing 2018년 6월 24일
댓글: MoeIsKing 2018년 6월 25일
warning matlab beginner here :-/
I would like to calculate the high and low pulselength from a real signal, if it is over 10 it is high under 10 it is low. Signal consists of 2002x2 numbers, time and voltage from a light bar...
If i import it with matlab i get 2 seperate double variables, voltage and time as "2002x1 double".
Now to segment the high pulse:
highSignals = signal > 10
Now i can count the high numbers (logic 1) and if i knwo the time distance from before i have the length.
Like: NumberofOnes=50 HighTime=dt*NumberofOnes
Can anyone give me a tip which function does that easyier or more structurised?

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 6월 24일
If you have Image Processing Toolbox, then one option is to use regionprops() to find the length of all the high areas and then average them to get a better estimate of highTime.
dt = mean(diff(second)); % sampling time
highRegions = regionprops(Volt>10, 'Area');
averageNumberofOnes = mean([highRegions.Area]);
highTime = averageNumberofOnes*dt;
  댓글 수: 2
Image Analyst
Image Analyst 2018년 6월 24일
Moes, if you want all the lengths of the valid sections individually you can do
allAreas = [highRegions.Area];
allTimes = dt * allAreas;
MoeIsKing
MoeIsKing 2018년 6월 25일
yep thats the one :-P
i got the Image Processing Toolbox somehow ^^ nice thanks

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by