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!