How to get the phase angle for an extracted fft plot?
7 views (last 30 days)
Show older comments
Goodnight,
Basically I had a signal and ran the fft command, which I then extracted a specific section of the fft plot. Now for that section I'll like to find the associated phase angle. Below is my code.
%%Import the mp3 file
[y,Fs] = audioread('Voice010.mp3');
%% Calculate size of the imported data
nfft = length(y);% length of the fft x=fft(y,nfft); mx=abs(x);%Absolute value f=Fs*(0:(nfft-1))/nfft;% Convert Time to the Frequency Domain mp3data = [f' mx];
%% Graph Displaying entire signal #1
figure(1); plot(f,mx,'-m','linewidth',0.25); xlim([80 500]); grid on; xlabel('Frequency,(Hz)'); ylabel('Amplitude,(Dimensionless)'); title('Sound Sample');
%% Extracting Data
mx_prime = mx>1000;
%% This matrix below contains all values for the amplitude greater than 1000
mx_1000 = mp3data(mx_prime,:);
%% Set the x limits
f_prime = (mx_1000(:,1)>80 & mx_1000(:,1)<250);
%% Combine the extracted data
mp3data_extracted = mx_1000(f_prime,:);
%% Graph displaying the extracted data #2
figure(2); hold on; plot(f,mx,'-m','linewidth',0.25); hold on; plot(mp3data_extracted(:,1),mp3data_extracted(:,2),'-b','linewidth',0.25); legend('Initial Data','Extracted data'); xlim([80 500]); grid on; xlabel('Frequency,(Hz)'); ylabel('Amplitude (Dimensionless)'); title('Sound Sample');
%% Graph 3 displaying the phase angle p=unwrap(angle(x)); figure(3); hold on; plot(f,p); xlim([80 500]); grid on; xlabel('Frequency,(Hz)'); ylabel('Phase / \pi'); title('Sound Sample');
0 Comments
Answers (1)
Star Strider
on 15 Feb 2017
‘I'll like to find the associated phase angle’
It seems to me you did that here:
p=unwrap(angle(x));
If you take the Fourier transform of the entire signal, there is no way for you to identify afterwards what a part of the signal contributed to the entire Fourier transform. You have to use the spectrogram function to get a time-frequency analysis. I have not attempted to get phase information from the spectrogram output, so I leave it to you to experiment with that.
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!