4-PAM simulation

7 次查看(过去 30 天)
Greg Girard
Greg Girard 2015-10-11
评论: Greg Girard 2015-10-13
Hello, I am working on a simulation of reading an audio signal into a 4-PAM modulator and demodulating in on the other side. I have Matlab and the Signal Processing toolbox that has the PAM modulator in it. I am having issues trying to format the data into the correct context to get the modulation to work. My current script is shown below:
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
ax1 = subplot(2,1,1);
ax2 = subplot(2,1,2);
%Plot the input signal and the digitized version
t1=[1/origFs:1/origFs:length(origY)/origFs];
plot(ax1,t1,origY)
%upsample the original date to nyquist rate
upY = upsample(y,2);
t2=[1/nyRate:1/nyRate:length(upY)/nyRate];
%add a plot
plot(ax2,t2,upY)
So I am analyzing the input signal for the sampling rate and then switching to the nyquist rate to double the sampling rate of the original. This is where I would think I would be able to put the information into the modulator but the modulator only accepts values from [0,M-1 (or 3 in this case)]. So I need to translate or scale the information into an acceptable input for the PAM modulator to work. Please help me out when you get a chance.
  1 个评论
Greg Girard
Greg Girard 2015-10-13
Additional help.
So I now have the PAM modulated envelope and I am trying to combine that with an AM carrier wave but I am having a hard time combining them because of the size and matrices.
if true
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 2 -1 1])
%Am carrier frequency is between 535-1605kHz
carrier = 1605000;
cWave = cos(carrier*t2);
subplot(2,3,5)
plot(t2,cWave)
title('Carrier wave')
%axis([0 10*(1/1605000) -1 1])
subPam = z(1:1000,:);
subCarrier = cWave(:,1:1000);
t3=[1/nyRate:1/nyRate:length(upY)/nyRate];
modWave = subPam*subCarrier;
subplot(2,3,6)
plot(t2,modWave);
end
So I can't just mix them together because they're both 46584x1 matrices (so the result is too large). I tried to make a sub sample of the first 1000 samples to try to modulate some at a time but I can't get the time to match up and they must be the same length. The modWave length is 1000x1000. Little help....still not super great at matlab.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2015-10-11
You need to quantize the signal to get a result 0 to 3 and put that result through the modulator.
  4 个评论
Greg Girard
Greg Girard 2015-10-12
Thank you for the help Walter. One more question for you (or anyone). So with these values, do I convert them to binary values first (dec2Bin) or do I just put these right into the pammod to get the correct output?
Walter Roberson
Walter Roberson 2015-10-12
You pass them directly, like is documented for pammod
The message signal must consist of integers between 0 and M-1.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modulation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by