Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I was just wondering if anyone could help me with my code, I am unsure how I would add a PhaseFrequencyOffset command. I read

Hi I was just wondering if anyone could help me with my code, I am unsure how I would add a PhaseFrequencyOffset command. I read on MathWorks that you can use H = comm.PhaseFrequencyOffset(Name,Value), but I'm not entirely sure how id write this, as every time ive attempted it, it never has any effect on the wave. What I'm basically looking to do is use both the frequency and phase separately so I can compare the two results afterwards, I want the offsets to only show on the demodulator signal, so id assume there's more code I need to add than just the main command. Ill leave my current code below but any help would be appreciated as ive been stuck on this for a couple days now. close all clear all clc %%echo on t0=.15; % signal duration ts=1/1500; % sampling interval fm=3/0.15; % message signal frequency fc=250; % carrier frequency a=5; % Modulation index a = amplitude of message/ amplitude of carrier fs=1/ts; % sampling frequency t=[0:ts:t0]; % time vector df=0.3; % desired frequency resolution % message signal m=[ones(1,t0/(3*ts)),-2*ones(1,t0/(3*ts)),zeros(1,t0/(3*ts)+1)]; m=cos(2*pi*fm.*t); c=cos(2*pi*fc.*t); % carrier signal u=m.*c; % modulated signal m_n=m/max(abs(m)); % normalized message signal u=(1+a*m_n).*c; % modulated signal %received signal y=u.*c; % mixing %Local oscillator - change the frequency and phase of c by desired values [M,m,df1]=fftseq(m,ts,df); % Fourier transform M=M/fs; % scaling [U,u,df1]=fftseq(u,ts,df); % Fourier transform U=U/fs; % scaling [Y,y,df1]=fftseq(y,ts,df); % Fourier transform Y=Y/fs; % scaling f_cutoff=150; % cutoff freq. of the filter n_cutoff=floor(150/df1); % Design the filter. f=[0:df1:df1*(length(y)-1)]-fs/2; H=zeros(size(f)); H(1:n_cutoff)=2*ones(1,n_cutoff); H(length(f)-n_cutoff+1:length(f))=2*ones(1,n_cutoff); DEM=H.*Y; % spectrum of the filter output dem=real(ifft(DEM))*fs; % filter output % the effect of mixing. figure(1); subplot(3,1,1) plot(m(1:length(t))) title('Waveform of the Message Signal') xlabel('Time') subplot(3,1,2) plot(u(1:length(t))) title('Waveform of the Modulated Signal') xlabel('Time') subplot(3,1,3) plot(y(1:length(t))) title('Waveform of the Mixer Output') xlabel('Time') figure(2); subplot(3,1,1) plot(f,fftshift(abs(M))) title('Spectrum of the Message Signal') xlabel('Frequency') subplot(3,1,2) plot(f,fftshift(abs(U))) title('Spectrum of the Modulated Signal') xlabel('Frequency') subplot(3,1,3) plot(f,fftshift(abs(Y))) title('Spectrum of the Mixer Output') xlabel('Frequency') % the effect of filtering on the mixer output. figure(3); subplot(3,1,1) plot(f,fftshift(abs(Y))) title('Spectrum of the Mixer Output') xlabel('Frequency') subplot(3,1,2) plot(f,fftshift(abs(H))) title('Lowpass Filter Characteristics') xlabel('Frequency') subplot(3,1,3) plot(f,fftshift(abs(DEM))) title('Spectrum of the Demodulator output') xlabel('Frequency') % to compare the spectra of the message and the received signal. figure(4); subplot(2,1,1) plot(f,fftshift(abs(M))) title('Spectrum of the Message Signal') xlabel('Frequency') subplot(2,1,2) plot(f,fftshift(abs(DEM))) title('Spectrum of the Demodulator Output') xlabel('Frequency') % the message and the demodulator output signals. figure(5); subplot(2,1,1) plot(t,m(1:length(t))) title('The Message Signal') xlabel('Time') subplot(2,1,2) plot(t,dem(1:length(t))) title('The Demodulator Output') xlabel('Time')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

LO4 Specify how to design a training program for adult learners.

Answered: 1 week ago