Effacer les filtres
Effacer les filtres

How to plot the spectrum of a high frequency sine wave of above 1GHz

15 vues (au cours des 30 derniers jours)
Praveen kumar
Praveen kumar le 13 Fév 2014
Commenté : Praveen kumar le 17 Fév 2014
Please help me with the matlab code

Réponse acceptée

Wayne King
Wayne King le 13 Fév 2014
Do you have the Signal Processing Toolbox:
Fs = 4e9;
t = 0:1/Fs:0.001-(1/Fs);
x = cos(2*pi*1.5e9*t);
[Pxx,F] = periodogram(x,[],length(x),Fs,'power');
plot(F,Pxx)
If you do not, you can use fft()
xdft = fft(x);
xdft = xdft(1:length(x)/2+1); % works for even length x
deltaf = Fs/length(x);
freqvec = 0:deltaf:Fs/2;
plot(freqvec,abs(xdft))
Note that latter is not scaled.
  3 commentaires
Praveen kumar
Praveen kumar le 14 Fév 2014
After performing autocorrelation to sinusoidal signal, i'm not getting the spectrum at high frequencies.
Praveen kumar
Praveen kumar le 17 Fév 2014
I have written the following code inorder to determine the Spectrum of autocorrelated noisy sine signal. But, I'm not able to get the spectrum for higher frequencies above 1MHz. Please inform where i have to change the code... close all; clear all; clc; %% Time specifications: Fs = 1e4; % samples per second dt = 1/Fs; % seconds per sample StopTime = 1; % seconds t = (0:dt:StopTime-dt)'; N = size(t,1);
%%Sine wave:
Fc = 1e3; % hertz
x = sin(2*pi*Fc*t);
noisy_x = x + 0.5*randn(size(x));
y = xcorr(noisy_x,5e3,'biased');
display(size(y));
subplot(2,1,1);
plot(t,x);
title('Sine signal');
subplot(2,1,2);
plot(t,noisy_x);
title('Noisy signal');
%%Fourier Transform:
X = fftshift(fft(y));
%%Frequency specifications:
dF = Fs/N; % hertz
f = -Fs/2:dF:Fs/2; % hertz
display(size(f));
display(size(X));
%%Plot the spectrum:
figure;
plot(f,abs(X)/N);
xlabel('Frequency (in hertz)');
title('Autocorrelation spectrum');

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by