Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

pulse with modulation

1 visualizzazione (ultimi 30 giorni)
cherif nacim
cherif nacim il 24 Feb 2011
Risposto: Akira Agata il 17 Apr 2023
how to implement the pulse with modulation with matlab
  1 Commento
Paulo Silva
Paulo Silva il 24 Feb 2011
function sig=pwmgen(f,d,np)
%plot(pwmgen(100,0.5,4));axis([0 50 -2 2])
%f is the frequency of the pulses
%d is the dutty cycle (value from 0 to 1)
%np is the number of pulses
t=0:1e-3:np*1/f;
ton=d*1/f;
toff=(1-d)*1/f;
nton=find(((t>(toff-1e-3))) & (t<(toff+1e-3)));
ntoff=find(((t>(ton-1e-3))) & (t<(ton+1e-3)));
if ton==0, nton=0,end
if toff==0, ntoff=0,end
s=[ones(1,nton) zeros(1,ntoff)];
sig=repmat(s,1,np);

Risposte (1)

Akira Agata
Akira Agata il 17 Apr 2023
If you have the Communications Toolbox, how about using commsrc.pattern ?

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by