FFT-based Spectrum Tool

Medium MATLAB DSP
Solve this problem

Write a MATLAB function to compute FFT of a signal and return frequency and magnitude spectrum. Normalize magnitude.

Constraints

  • Function signature: [f,mag]=spec(x,Fs)
  • Use fft.
  • Use abs.
  • Single-sided spectrum.
  • mag normalized to max=1.
Starter codeMATLAB
1function [f,mag] = spec(x,Fs)2% TODO3end