plotting signals in frequency domain

105 Ansichten (letzte 30 Tage)
Sadi M Jawad Ahsan
Sadi M Jawad Ahsan am 8 Mai 2022
Kommentiert: William Rose am 8 Mai 2022
Q: In the operation of V.34 class voiceband modems, tone signals that are narrowly spaced apart must be quickly identified for initialization. We want to design a signal processing algorithm that can easily detect which signal is received. ITU-T V.25 and V.8 recommendations specify the signals as
𝑠0(𝑡) = 𝐴0 cos(2𝜋𝑓c𝑡 + 𝜃) : ANS signal
𝑠1(𝑡) = 𝐴1[1 + 𝜌 cos(2𝜋𝑓0t + 𝜙)] cos(2𝜋𝑓c𝑡 + 𝜃) : ANSam signal
The parameters are given by: 𝜌 = 0.2, 𝑓0 = 15 Hz, 𝑓c = 2100 Hz, 𝐴1 = 1, 𝐴0 = 𝐴1(1 +𝜌^2/2) Thevalues for 𝜃 and 𝜙 are arbitrary.
2. Plot the magnitudes of the Fourier transforms of the two signals. Confirm that ANS is a single tone and ANSam is a sum of three narrowly spaced tones. What is the spacing between the tones in the ANSam signal? [Hint: In order to have a high frequency resolution, the FFT points N must be large enough. Also, you might want to zoom into around f = 2100 Hz to be able to see the narrowly spaced tones clearly.]
My code:
p = 0.2;
f0 = 15;
fc = 2100;
A1 = 1;
A0 = A1 * ((1 + ((p.^2)/2)))*0.5;
n = 2^nextpow2(L);
theta = -pi+2*pi*rand(1, n);
phi = -pi+2*pi*rand(1, n);
fs = 4*fc*((2*n)+1); % Sampling frequency
T = 1/fs; % Sampling period
L = fs; % Length of signal
t = linspace(0, T, n); %(0:L-1)*T; % Time vector
s0 = A0 .* cos((2*pi*fc*t)+theta); % ANS signal
s1 = A1 .* (1+(p*cos((2*pi*f0*t)+phi))) .* cos((2*pi*fc*t)+theta); % ANSam signal
X = [s0; s1];
dim = 2;
Y = fft(X,n,dim);
P2 = abs(Y/L);
P1 = P2(:,1:n/2+1);
P1(:,2:end-1) = 2*P1(:,2:end-1);
for i=1:2
subplot(2,1,i)
plot(0:(fs/n):(fs/2-fs/n),P1(i,1:n/2))
title(['Row ',num2str(i),' in the Frequency Domain'])
end
Problem: Not getting output. Need help

Akzeptierte Antwort

William Rose
William Rose am 8 Mai 2022
@Sadi M Jawad Ahsan, Here is an example of what I was saying in my previous answer. Note that I define a vector of time values (t) early in the script. I use that vector to compute s1 and s2. I use upper case S1 and S2 to refer to the Fourier transforms of s1 and s2.
%constants provided in the problem statement
p = 0.2;
f0 = 15;
fc = 2100;
A1 = 1;
theta=2*pi*rand(1);
phi=2*pi*rand(1);
%constants I compute
fs=5*fc; %sampling rate (Hz)
dt=1/fs; %sampling interval (s)
T=1; %total signal duration (s)
N=T*fs; %points in the signal
t=(0:N-1)*dt; %vector of time values
df=1/T; %frequency resolution of the FFT
f=(0:N-1)*df; %vector of frequencies for the FFT
%compute the signals
A0 = A1 * ((1 + ((p.^2)/2)))*0.5;
s0 = A0 * cos(2*pi*fc*t+theta); % ANS signal
s1 = A1 * (1+p*cos(2*pi*f0*t+phi)) .* cos(2*pi*fc*t+theta); % ANSam signal
%compte the FFTs
S0 = fft(s0);
S1 = fft(s1);
%plot the entire two-sided amplitude spectra
figure;
subplot(211), plot(f,abs(S0),'-r',f,abs(S1),'-b');
xlabel('Frequency (Hz)'); ylabel('Amplitude'); grid on
legend('|S0|','|S1|')
%plot the amplitude spectra from 2050 to 2150 Hz
subplot(212), plot(f,abs(S0),'-r',f,abs(S1),'-b');
xlabel('Frequency (Hz)'); ylabel('Amplitude'); grid on
legend('|S0|','|S1|'); xlim([2050,2150])
Try it.
  2 Kommentare
Sadi M Jawad Ahsan
Sadi M Jawad Ahsan am 8 Mai 2022
fs is given as 4fc(2n+1). Why are you using fs=5fc?
William Rose
William Rose am 8 Mai 2022
I explained why I use fs=5*fc in my original post.
You interpret "n" to mean the number of points in the FFT. If so, then the definition �s=1/𝑇s=4𝑓c(2𝑛 + 1) makes no sense, and is simply wrong. I supose that n could mean something else, and that, with some alternative deifnition of n, the equation fs=1/𝑇s=4𝑓c(2𝑛 + 1) could be reasonable.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

William Rose
William Rose am 8 Mai 2022
Bearbeitet: William Rose am 8 Mai 2022
[correcting my spelling mstakes]
You have made an excellent start on the problem.
I do not understand your choice of fs. I recommend that you choose fs=5*fc, i.e. sample at 5 times the rate of the main frequency in th problem. This is not really all that fast, because it means you use 5 samples per cycle of the sinusoid, i.e. one point every 72 degrees of phase. I recommend that you construct signals with a duration of 1 second or more. This guarantees that the frequency resolution of the FFT will be 1 Hz (freq resolution=1/duration). If you want a resolution of 0.5 Hz, the signals should be 2 seconds long.
Make a vector of frequencies, which will be the x-axis values of the plot.
Then compute the FFTs, take the absolute value, and plot.
  3 Kommentare
Sadi M Jawad Ahsan
Sadi M Jawad Ahsan am 8 Mai 2022
Another issue is how to show that a signal comprises of three different tones?
William Rose
William Rose am 8 Mai 2022
@Sadi M Jawad Ahsan, the plot generated by my code, shown in my answer below, shows three distinct peaks in the S1 spectrum. This indicates three tones: the carrier and the two sidebands. You probably know this, but just in case you don;t this is a classic case of amplitude modulation. p is the modulation index, which should never exceed unity. If you increase p, the sideband amplitude will increase.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by