How to transfer RF signal to Frequency Domain?

3 次查看(过去 30 天)
Hi Experts,
I tried to create a similar signal below. Now the Time Domain is worked only, it's strange to me.
I don't understand why that Frequency is incorrect when I plot on Frequency Domain.
Would you please share your comments?
Fin = 200e3; % Frequency Signal
DutFs = 200e6; % Sampling frequency
Impedance = 50;
t = 0:(1/DutFs):(1/DutFs)*3000;
OriSignal = (0.49505106597641246)*sin(2*pi*Fin*t); % Signal, 3.893 dBm.
HarmonicFin2 = (0.0012331048332289098)*sin(2*pi*Fin*2*t); % Harmonic2, -48.19 dBm.
HarmonicFin3 = (0.0015631476426409539)*sin(2*pi*Fin*3*t); % Harmonic3, -46.13 dBm.
HarmonicFin4 = (0.00011953635256737178)*sin(2*pi*Fin*4*t); % Harmonic4, -68.46 dBm.
MixedSignal = OriSignal + ... % Amplitude is from 1.15V to 0.15V.
+ HarmonicFin2...
+ HarmonicFin3...
+ HarmonicFin4 + 0.65;
subplot(2,1,1);
plot (t,MixedSignal), grid on;
title("TimeDomain");
ylabel("amplitude(V)");
xlabel("time(s)");
Power_dBm = 10*log10((((MixedSignal*0.707).^2)/Impedance)*1000); % Calculate dBm from Voltage.
NumberofSample = length(Power_dBm);
FreqRange = linspace(100e3,1000e3,3001); % Define X-Axis range.
power = fft(Power_dBm);
subplot(2,1,2);
plot(FreqRange,Power_dBm);

回答(1 个)

Nithin
Nithin 2023-11-2
Hi Simo,
I understand that you were able to plot the RF signal in the time domain and want to know how to plot the same in the frequency domain.
Kindly modify your code with the following steps to implement the same:
  1. To plot the signal in the frequency domain, you should plot “abs(power)” against the corresponding frequency axis.
  2. Modify the frequency axis based on the sampling frequency and the number of samples.
To plot the required signal in the frequency domain, kindly refer to the following code snippet:
Fin = 200e3; % Frequency Signal
DutFs = 200e6; % Sampling frequency
Impedance = 50;
t = 0:(1/DutFs):(1/DutFs)*3000;
OriSignal = (0.49505106597641246)*sin(2*pi*Fin*t); % Signal, 3.893 dBm.
HarmonicFin2 = (0.0012331048332289098)*sin(2*pi*Fin*2*t); % Harmonic2, -48.19 dBm.
HarmonicFin3 = (0.0015631476426409539)*sin(2*pi*Fin*3*t); % Harmonic3, -46.13 dBm.
HarmonicFin4 = (0.00011953635256737178)*sin(2*pi*Fin*4*t); % Harmonic4, -68.46 dBm.
MixedSignal = OriSignal + HarmonicFin2 + HarmonicFin3 + HarmonicFin4 + 0.65;
subplot(2,1,1);
plot(t, MixedSignal), grid on;
title("Time Domain");
ylabel("Amplitude (V)");
xlabel("Time (s)");
Power_dBm = 10*log10((((MixedSignal*0.707).^2)/Impedance)*1000); % Calculate dBm from Voltage.
NumberofSample = length(Power_dBm);
% Calculate the frequency axis
deltaF = DutFs / NumberofSample; % Frequency resolution
f = (-DutFs/2 : deltaF : DutFs/2 - deltaF); % Frequency axis
power = fftshift(fft(Power_dBm));
subplot(2,1,2);
plot(f, abs(power));
title("Frequency Domain");
ylabel("Magnitude");
xlabel("Frequency (Hz)");
xlim([-1e5, 1e5]);
For more information regarding “abs”, “fft” and “fftshift”, kindly refer to the following documentation:
I hope this answer provides you with the required information regarding your query.
Regards,
Nithin Kumar.

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by