Analysing PWM duty cycle of a signal
    13 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I have recorded a PWM signal from a given device.
I require to determine the duty cycle(s) of the signal as the transitions from one state to another.
How may I output the duty cycle of the PWM thoughout the signal?
I am using Matlab 2016b
0 件のコメント
回答 (1 件)
  David Hill
      
      
 2023 年 3 月 20 日
        s=pwm>threshold;%pwm is your signal, threshold is when it is considered on or off
d=diff(s);
idx1=find(s,1);
idx2=find(d==-1);
idx3=find(d==1);
num=idx2-[idx1-1,idx3(1:end-1)];
denom=diff([idx1-1,idx3]);
dutyCycle=num./denom;
3 件のコメント
  David Hill
      
      
 2023 年 3 月 21 日
				
      編集済み: David Hill
      
      
 2023 年 3 月 21 日
  
			I assumed your data was a horizontal array. For a better response, attach your data.
s=CH01_01(:)';%convert to horizontal array
s=s>.75;
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!