Making a pulse train function, given pulse width and period
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Steve
le 15 Avr 2014
Réponse apportée : Star Strider
le 15 Avr 2014
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 commentaires
Réponse acceptée
Star Strider
le 15 Avr 2014
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Waveform Generation dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!