PAM graphs and errors

2 次查看(过去 30 天)
Greg Girard
Greg Girard 2015-10-13
Hello, I have been attempting to create a 4-PAM system with a sound file for an input and have the following code and graphs but obviously something seems wrong. Any tips for me?
clc;
close all;
clear all;
%Turn the WAV file into digital data
%Accept a filename as the input
fileIn = 'dog_dare2.wav';
info = audioinfo(fileIn);
nyRate = info.SampleRate*2;
%extract the information
%set the sampling frequency to twice that of the file
%Extract the data and the sample rate
[origY,origFs] = audioread(fileIn);
%Play the sound back
%sound(origY,origFs)
figure
%Plot the input signal and the digitized version
t1=[1/origFs:1/origFs:length(origY)/origFs];
subplot(2,3,1)
plot(t1,origY)
title('Sound input')
axis([0 2 -1 1])
subplot(2,3,2)
plot(t1,origY)
title('Sound input zoomed in')
axis([0 0.1 -1 1])
%upsample the original date to nyquist rate
upY = upsample(origY,2);
t2=[1/nyRate:1/nyRate:length(upY)/nyRate];
%add a plot
subplot(2,3,3)
plot(t2,upY)
title('Nyquist rate')
axis([0 0.1 -1 1])
%sound(upY,nyRate)
m = min(max(-2, floor(upY/0.5)),1)+2;
z = pammod(m,4);
subplot(2,3,4)
plot(t2,z)
title('PAM modulation envelope')
axis([0 3 -5 5])
%Am carrier frequency is between 535-1605kHz
carrier = 535000;
cWave = 5*cos(2*pi*carrier*t2);
cWave = transpose(cWave);
subplot(2,3,5)
plot(t2,cWave)
title('Carrier wave')
axis([0 3 -10 10])
modWave = z.*cWave;
subplot(2,3,6)
plot(t2,modWave);
title('Carrier and Modulation')
axis([0 5 -20 20])

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by