Making a pulse train function, given pulse width and period

6 ビュー (過去 30 日間)
Steve
Steve 2014 年 4 月 15 日
回答済み: Star Strider 2014 年 4 月 15 日
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

採用された回答

Star Strider
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 件)

カテゴリ

Help Center および File ExchangeWaveform Generation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by