MATLAB Answers

NO GRAPH IN MY FIGURE PLOTTING (designing a highpass FIR with blackman windowing)

3 views (last 30 days)
Joshua Tampubolon
Joshua Tampubolon on 3 Jun 2020
%group 6
%Joshua Yoshihiko, Nadhila Hanan, Atya Saniah
clc;
clear all;
close all;
%input audio file with format: *.wav
%=========
[samAud,samRate]=audioread('bayi.wav');
N=1024;
f=0:samRate/(N/2-1):samRate;
samAud_fft = fft(samAud,N);
%=========
%plot audio file in time domain
%=========
figure (1)
plot(samAud);
%=========
%plot audio file in frequency domain
%=========
figure (2)
plot (f,abs(samAud_fft(1:N/2))/max(abs(samAud_fft(1:N/2))));
%=========
%Design FIR filter
%start here
fc=2000;
M=100;
n=0:1:M;
%write the desired/reference filter function
hd=(sinc(n-M/2)-(fc/samRate)*(sinc((fc/samRate)*(n-M/2))));
%write code for window method you use
wn=0.42-0.5*(cos(2*pi*(n/M)))+0.08*(cos(4*pi*(n/M)));
%write the designed filter function
hn=hd.*wn;
%apply filter to the audio file
samAud_filtered=conv(samAud,hn);
samAud_fft_filtered=fft(samAud_filtered,N);
%plot filtered audio file in time domain
figure (3)
plot(samAud_filtered);
%plot filtered audio file in frequency domain
figure (4)
plot(f,abs(samAud_fft_filtered(1:1:N/2))/max(abs(samAud_fft_filtered(1:1:N/2))));
%end here

Answers (0)