简体   繁体   中英

How to plot the magnitude and phase of a frequency?

I was reading Practical Introduction to Frequency Domain Analysis . It shows how to observe the frequency content of a signal using this code:

Fs = 44100;
y = audioread('guitartune.wav');

NFFT = length(y);
Y = fft(y,NFFT);
F = ((0:1/NFFT:1-1/NFFT)*Fs).';

magnitudeY = abs(Y);        % Magnitude of the FFT
phaseY = unwrap(angle(Y));  % Phase of the FFT

helperFrequencyAnalysisPlot1(F,magnitudeY,phaseY,NFFT)

The function that plots is the helperFrequencyAnalysisPlot1 . I need to know how the function does the plotting but the article never shows how. How is it actually done?

These are Matlab built-in examples so you have to type in the Command Window

edit('helperFrequencyAnalysisPlot1.m')

A new Matlab editor tab will pop up, showing you the function (both its definition and the code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM