kowaii
Newbie level 1
- Joined
- Mar 5, 2013
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,292
Hi everyone,
I have a wave of frequency 100 Hz (it is a set of data). I would like to plot the amplitude and the phase angle vs frequency. This is what I do but my amplitude shows at the wrong frequency, what am I missing?
given x=[....] set of data representing wave of frequency = 100 Hz, of length 1500.
first: Nfft = 2^nextpow2(length(x));
second: Fs = 1000; (that is 10 times my frequency of 100, is that correct?)
third: get fft : xdft = fft(x,Nfft);
forth: get amplitude: amp = abs(xdft);
fifth: get phase : ang = unwrap(angle(xdft));
Now my main issue is to set up the frequency vector correctly, this is what i did
f_fold = Fs/2; % folding frequency = max frequency of FFT (Hz)
T = Nfft/Fs % total sample time (s)
del_f = 1/T; % (Hz)
f_v = [0:del_f:f_fold]'; % frequency (Hz)
I also tried matlab's suggestion: f_v = Fs*(0:Nfft-1)/Nfft
But my amplitudes always show at the wrong frequency. What can I do to fix this? Thank you
PS: my attempts are taken from the web, they are not purely my work, just mentioning that for the record.
I have a wave of frequency 100 Hz (it is a set of data). I would like to plot the amplitude and the phase angle vs frequency. This is what I do but my amplitude shows at the wrong frequency, what am I missing?
given x=[....] set of data representing wave of frequency = 100 Hz, of length 1500.
first: Nfft = 2^nextpow2(length(x));
second: Fs = 1000; (that is 10 times my frequency of 100, is that correct?)
third: get fft : xdft = fft(x,Nfft);
forth: get amplitude: amp = abs(xdft);
fifth: get phase : ang = unwrap(angle(xdft));
Now my main issue is to set up the frequency vector correctly, this is what i did
f_fold = Fs/2; % folding frequency = max frequency of FFT (Hz)
T = Nfft/Fs % total sample time (s)
del_f = 1/T; % (Hz)
f_v = [0:del_f:f_fold]'; % frequency (Hz)
I also tried matlab's suggestion: f_v = Fs*(0:Nfft-1)/Nfft
But my amplitudes always show at the wrong frequency. What can I do to fix this? Thank you
PS: my attempts are taken from the web, they are not purely my work, just mentioning that for the record.