Making a pulse train function, given pulse width and period
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi, I'm trying to make a function, that takes in the pulse width, tau, and the period that each pulse is centred at, T, but I'm having some trouble
Here's what I have:
function [ x ] = pulse( T,tau )
D = [T]; % pulse delay times
t = -T : 1/fs : 2T; % signal evaluation time
w = tau; % width of each pulse
x = pulstran(t,D,@rectpuls,w);
y = rectpuls(t,tau);
plot(x);
plot(y);
end
댓글 수: 0
채택된 답변
Star Strider
2014년 4월 15일
This works:
pulse = @(T,tau, fs) [zeros(1, round(fs*(T-tau/2))) ones(1, round(fs*tau)) 0];
fs = 100;
T = 15;
tau = 5;
sqpulse = pulse(T,tau, fs);
figure(1)
plot( [1:length(sqpulse)]/fs, sqpulse)
axis([xlim 0 1.1])
grid
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Waveform Generation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!