why PSD is different?

6 views (last 30 days)
Ahmed
Ahmed on 7 Jun 2013
Answered: Gaurav on 26 Apr 2023
Hello all, I am new to digital signal processing. I understand that there are 2 ways to get the PSD of a signal: 1- by fft the auto-correlation of the signal 2- by multiplying the fft of the signal by its conjugate. when I use these 2 methods in matlab on a maximum-length PRBS signal I always get different results! can you explain it for me ? here is my code:
x=idinput(2^14-1,'PRBS') % prbs
[rxx lags]=xcorr(x)
X=fft(x,length(x))
rxx_temp=rxx(1:(length(x)))
rxx_temp=fliplr(rxx_temp')
rxx=rxx_temp'
Rxx1=fft(rxx)
subplot(211)
plot(abs(Rxx1))
title('S(f)=Rxx(f)=fft(rxx)')
Rxx2= X.*conj(X)
subplot(212)
plot(abs(Rxx2))
title('S(f)=Rxx(f)=X X*')

Answers (2)

Youssef  Khmou
Youssef Khmou on 7 Jun 2013
hi,
They are the same with your approach here is an example :
x=sin(2*pi*40*(0:1/90:10));
[rxx lags]=xcorr(x)
X=fft(x,length(x))
rxx_temp=rxx(1:(length(x)))
rxx_temp=fliplr(rxx_temp')
rxx=rxx_temp'
Rxx1=fft(rxx)
subplot(211)
plot(abs(Rxx1))
title('S(f)=Rxx(f)=fft(rxx)')
Rxx2= X.*conj(X)
subplot(212)
plot(abs(Rxx2))
title('S(f)=Rxx(f)=X X*')
  1 Comment
Ahmed
Ahmed on 7 Jun 2013
Thanks Youssef
The 2 methods give identical results if the input signal is sinusoidal, I just dont understand why the output is different when the input signal is a MLS prbs signal, although mathematically they must be the same !

Sign in to comment.


Gaurav
Gaurav on 26 Apr 2023
clc;
close all;
clear all;
% User Inputs
bit_size=input('Enter the bit size '); % Bit size is taken as input
nf=7; % Flip-flops in LFSR
% Feedback tap positions
taps=[6 7]; % taps in LFSR
ri=randi([0 1],1,nf); % LFSR with random seed inputlr=zeros(1,nf); % LFSR initialization
l=128; % PRBS length
ls=zeros(l,nf); % sequence initialization in LFSR
for i=1:l
% LFSR shift operation
y= sum(ri(taps)); % xor operation output
x= mod(y,2);
lr(2:end) = ri(1:end-1) ; % Shifting in LFSR
lr(1)=x;
% Feedback in LFSR
ri=lr;
% updating value of ri
ls(i,:)=lr;
% generation of LFSR Sequence
end

Community Treasure Hunt

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

Start Hunting!