How do I create and plot a pulse train from an existing pulse not using the pulse train function?
Show older comments
I have a pulse which uses a hann window and lasts 100 micro seconds. I need to create a pulse train over a period of a about 1 millisecond. I just need help with knowing what to put as my twin as you will see in the code below. With the twin I'm using I get an error:
??? Error using ==> plot
Vectors must be the same lengths.
How do I resolve this error?
fs = 1.5e6;%sample rate of 1,500,000
twin= 0: (1/150)/fs: 10e-3;
tpulse = ([1:150]-1)*(1/fs);
fc =130e3;%centre frequency of 130kHz
w = 2*pi*fc;%omega
y = real(exp([-1i*w*tpulse]));%sin wave
subplot(411);
plot(tpulse,y);
a = hann(150);%hanning window to give it click profile
y2 = y.*a';
subplot(412);
plot(twin,y2);
Y = fft(y2);
subplot(413);
plot(abs(Y));
subplot(414);
plot(y2);
Answers (1)
Paulo Silva
on 2 Mar 2011
One of the correct ways to define the pulse and the train is:
tpulse = 0:1/fs:100e-6; %100 micro seconds
twin= 0:1/fs: 1e-3; %1 mili second
The rest of the code needs to be fixed, I wonder if:
fs = 1.5e6;%sample rate of 1,500,000
tpulse = 0:1/fs:100e-6; %100 micro seconds
twin= 0:1/fs: 1e-3; %1 mili second
fc =130e3;%centre frequency of 130kHz
w = 2*pi*fc;%omega
y = real(exp([-1i*w*twin]));%sin wave
subplot(411);
plot(twin,y);
a = hann(numel(twin));%hanning window to give it click profile
y2 = y.*a';
subplot(412);
plot(twin,y2);
Y = fft(y2);
subplot(413);
plot(abs(Y));
subplot(414);
plot(y2);
1 Comment
Paulo Silva
on 2 Mar 2011
Here's a way to create twin from tpulse
twin=tpulse:1/fs:1e-3; %1 mili second
and a way to create tpulse from twin
tpulse=twin(1:find(twin==1e-3))
Categories
Find more on Waveform Generation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!