www.gusucode.com > signal 案例源码程序 matlab代码 > signal/DutyCycleOfBilevelWaveformWithThreePulsesExample.m
%% Duty Cycle of Bilevel Waveform with Three Pulses % Create a pulse waveform with three pulses. The sample rate is 4 MHz. % Determine the initial and final mid-reference level instants. Plot the % result. %% load('pulseex.mat','x') fs = 4e6; pulse = x(1:30); wavef = [pulse;pulse;pulse]; t = (0:length(wavef)-1)/fs; [~,initcross,finalcross,~,midlev] = dutycycle(wavef,t) %% % Even though there are three pulses, only two pulses have corresponding % subsequent transitions. Plot the result. plot(t,wavef) hold on plot([initcross finalcross],midlev*ones(2),'x','markersize',10) hold off legend('Waveform','Initial','Final','Location','best')