DFT - How to label x-axis in frequency

5 vues (au cours des 30 derniers jours)
Wellington
Wellington le 22 Oct 2014
Commenté : Wellington le 22 Oct 2014
Hi,
I need to label my x-axis in frequency how can I do that ... follow my code
% function f2
N=length(f2);
n = 0:1:N-1; % row vector for n
k = 0:1:N-1; % row vecor for k
WN = exp(-1j*2*pi/N); % Twiddle factor (w)
nk = n'*k; % creates a N by N matrix of nk values
WNnk = WN .^ nk; % DFT matrix
Xk = (WNnk*f2 );
mag1=abs(Xk); ang1=(angle(Xk)*180)/pi;
Then here I need to plot an one sided fft Amplitude x Frequency.. Anyone can Help me???
  2 commentaires
Orion
Orion le 22 Oct 2014
Hi,
what is f2 ? it's not defined in your text, so we can't run it to try your code.
Wellington
Wellington le 22 Oct 2014
Sorry
n=0:1:127;
dt2=.01;
phase=0.6108652382;
f2=sin(2*pi*4*n*dt2 + phase);
this is the previous part of the code

Connectez-vous pour commenter.

Réponses (1)

Orion
Orion le 22 Oct 2014
Modifié(e) : Orion le 22 Oct 2014
your line
Xk = (WNnk*f2 );
is not working. problem of dimensions : WNnk is 128x128 matrix and f2 is a 1x128.
maybe you just want to transpose ?
Xk = (WNnk*f2' );
anyway, make sure your data are at the expected dimensions and then just plot(f2,mag1) ?
  1 commentaire
Wellington
Wellington le 22 Oct 2014
Yes, I transposed f2, then the dimension is not the problem anymore.
But When I'am plotting the x-axis come up with the number between 0 and 128 and with both sides of DFT. I need one sided and frequency on x-axis
Thanks so much!!

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by