平顶脉冲幅度调制

Flat top Pulse Amplitude Modulation

我想绘制正弦曲线的平顶 PAM。使用 matlab 波。 正弦信号的频率 = 10^4/(2*pi) HZ,采样频率 = 8 kHZ。脉冲持续时间 T = 50 微秒。 我写了自然采样的代码,那么平顶怎么做?

clear all;
close all;
Fs = 1e9;
t = 0:1/Fs:(0.2e-2);
fc = 8000; %sampling frequency
fm = 10^4/(2*pi); %message frequency
a = 1;
vm = a.*sin(2*pi*fm*t); %message
pulseperiods = [0:10]*1/fc;
pulsewidth = 50e-6;
vc = pulstran(t,pulseperiods,@rectpuls,pulsewidth);
y = vc.*vm;
figure
subplot(3,1,1);
plot(t,vm); % plot message
xlabel('Temps');
ylabel('Amplitude');
title('Message');
subplot(3,1,2);
plot(t,vc); % plot pulse 
xlabel('Temps');
ylabel('Amplitude');
title('Switching waveform');
subplot(3,1,3);
plot(t,y); % plot PAM naturel
xlabel('Temps');
ylabel('Amplitude');
title('PAM naturel');

平顶PAM是指瞬时采样,即报文信号每个周期只采样一次,所以调制信号直到归零和下一个采样周期才改变其值。采样发生在载波信号的上升沿,因此解决方案非常简单:通过将 for 循环添加到您的代码中:

for i = 2:length(t)
    if vc(i) == 1 && vc(i-1) == 0 %if the rising edge is detected
        y1(i) = vc(i) * vm(i);    %sampling occurs
    elseif vc(i) == 1 && vc(i-1) == 1 %and while the carrier signal is 1
        y1(i) = y1(i-1);              %the value of y1 remains constant
    else
        y1(i) = 0;                %otherwise, y is zero
    end
end
plot(t,y1); % flat-top PAM plot
xlabel('Temps');
ylabel('Amplitude');
title('PAM flat-top');

你得到