Mag Phase

function mag_phase_plot(xfer,frame_div_fs)

figure

frame=length(xfer);

L = frame/2;

Fs = frame/frame_div_fs(1);  % compute sampling freq

xfer=xfer(1:L);

dB = 20*log10(abs(xfer));

fvec = (Fs/4)*(0:(L-1))/L;

subplot(2,1,1);

plot(fvec,dB); title(‘dB (magnitude) vs frequency’);

ylabel(‘dB’);xlabel(‘Hz’);

 

phase = (180/pi)*unwrap(atan2(imag(xfer),real(xfer)));

subplot(2,1,2);

plot(fvec,phase); title(‘phase (degrees) vs frequency’);

ylabel(‘degrees’); xlabel(‘Hz’)