SlideShare a Scribd company logo
Syed Abuzar Page 1
Encoder and Decoder using MATLAB
If u want help regarding this feel free to
contact 03129926454
1st
Program:
function varargout = Decodeeer(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Decodeeer_OpeningFcn, ...
'gui_OutputFcn', @Decodeeer_OutputFcn, ...
'gui_LayoutFcn', [] , ...
Syed Abuzar Page 2
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function Decodeeer_OpeningFcn(hObject, eventdata, handles,
varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = Decodeeer_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
function one_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=697; f_high=1209;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
Syed Abuzar Page 3
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise'); %it is function which store the input from a
function and it can be used in other functions.
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function two_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=697; f_high=1336;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
Syed Abuzar Page 4
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function three_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=697; f_high=1477;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
Syed Abuzar Page 5
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function four_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=770; f_high=1209;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
Syed Abuzar Page 6
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function five_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=770; f_high=1336;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
Syed Abuzar Page 7
function six_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=770; f_high=1477;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function seven_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
Syed Abuzar Page 8
N=5000;
f_low=852; f_high=1209;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function eight_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=852; f_high=1336;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
Syed Abuzar Page 9
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function nine_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=852; f_high=1477;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
Syed Abuzar Page 10
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function staric_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=941; f_high=1209;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
Syed Abuzar Page 11
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function zero_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=941; f_high=1336;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise'); %it is function which store the input from a
function and it can be used in other functions.
Syed Abuzar Page 12
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function hash_Callback(hObject, eventdata, handles)
clc
fs=8000;
t=0:1/fs:0.1;
N=5000;
f_low=941; f_high=1477;
y1=sin(2*pi*f_low*t);
y2=sin(2*pi*f_high*t);
y=y1+y2;
wavplay(y,fs);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y,N));
axes(handles.axes1);
plot(w,abs(H));
title('DTMF Input');xlabel('f(Hz)');
ylabel('Amplitude');grid;
x=getappdata(0,'Noise');
y1=awgn(y,x);
w=linspace(-fs/2,fs/2,N);
H=fftshift(fft(y1,N));
axes(handles.axes2);
Syed Abuzar Page 13
plot(w,abs(H), 'r');
title('FFT ');grid;
xlabel('f(Hz)');ylabel('Amplitude');
r=filtered(y1);
disp(r)
function noise_Callback(hObject, eventdata, handles)
x=str2double(get(handles.noise, 'String' ));
setappdata(0,'Noise',x);
function noise_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function info_Callback(hObject, eventdata, handles)
msgbox('File was created by : Syed
Abuzar Comsats Abbottabad
Reg # SP15-BEE-096
Submitted To : Mam Rabya','Info','warn')
function Close_Callback(hObject, eventdata, handles)
close;
2nd
Program:
function output = filtered(y)
fs=8000;
N=5000;
Hd1=lowpass_filter;
x1=filter(Hd1,y);
x1 = fft(x1,N);
[~,m1] = max(abs(x1));
Syed Abuzar Page 14
m1=m1*1.6;
% disp('max1')
% disp(m1)
Hd2=highpass_filter;
x2=filter(Hd2,y);
x2 = fft(x2,N);
[~,m2] = max(abs(x2));
m2=m2*1.6;
% disp('max2')
% disp(m2)
% L=[697,770,852,941];
% H=[1209,1336,1477];
if ((m1>692) && (m1<720))
m1=697;
elseif ((m1>765) && (m1<800))
m1=770;
elseif ((m1>847) && (m1<880))
m1=852;
elseif ((m1>936) && (m1<960))
m1=941;
end
% disp(m1)
if ((m2>1204) && (m2<1240))
m2=1209;
elseif ((m2>1331) && (m2<1360))
m2=1336;
elseif ((m2>1472) && (m2<2500))
m2=1477;
end
Syed Abuzar Page 15
% disp(m2)
j=m1; k=m2;
if j<=697 & k<=1209;
key = '1';
elseif j<=697 & k<=1336;
key = '2';
elseif j<=697 & k<=1477;
key = '3';
elseif j<=770 & k<=1209;
key = '4';
elseif j<=770 & k<=1336;
key = '5';
elseif j<=770 & k<=1477;
key = '6';
elseif j<=852 & k<=1209;
key = '7';
elseif j<=852 & k<=1336;
key = '8';
elseif j<=852 & k<=1477;
key = '9';
elseif j<=941 & k<=1209;
key = '*';
elseif j<=941 & k<=1336;
key = '0';
elseif j<=941 & k<=1477;
key = '#';
else
key= 'very noisy signal' ;
end
output=key;
end
Syed Abuzar Page 16
3rd
Program:
function Hd = lpfilter
]Fs = 8000; % Sampling Frequency
Fpass = 980; % Passband Frequency
Fstop = 1000; % Stopband Frequency
Dpass = 0.99980002; % Passband Ripple
Dstop = 0.0001; % Stopband Attenuation
dens = 20; % Density Factor
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]);
% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);
% [EOF]
4rth Program:
function Hd = highpass_filter
Fs = 8000; % Sampling Frequency
Fstop = 1100; % Stopband Frequency
Fpass = 1130; % Passband Frequency
Dstop = 0.0001; % Stopband Attenuation
Dpass = 0.99980002; % Passband Ripple
dens = 20; % Density Factor
Syed Abuzar Page 17
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fstop, Fpass]/(Fs/2), [0 1], [Dstop, Dpass]);
% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);
% [EOF]

More Related Content

PDF
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
PDF
Lambda expressions in C++
PDF
The Ring programming language version 1.5.4 book - Part 59 of 185
PDF
The Ring programming language version 1.7 book - Part 63 of 196
PPTX
Chapter 7 functions (c)
DOC
Ocr code
PDF
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
PPT
Lo Mejor Del Pdc2008 El Futrode C#
Writing SOLID C++ [gbgcpp meetup @ Zenseact]
Lambda expressions in C++
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.7 book - Part 63 of 196
Chapter 7 functions (c)
Ocr code
Sokoban Game Development Using Java ( Updated using Screenshots & Class Diagr...
Lo Mejor Del Pdc2008 El Futrode C#

What's hot (20)

PPTX
SANER 2019 Most Influential Paper Talk
PDF
Dynamic C++ ACCU 2013
PPTX
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
PDF
Microsoft Word Hw#1
PDF
Dynamic C++ Silicon Valley Code Camp 2012
DOC
Ds 2 cycle
DOCX
C programs
PDF
Asssignment2
PDF
Standford 2015 week9
PDF
The Ring programming language version 1.8 book - Part 65 of 202
PDF
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
PDF
The Ring programming language version 1.6 book - Part 62 of 189
DOCX
Advance java
PDF
Javascript & Ajax Basics
PDF
An introduction to thrust CUDA
PDF
Property-based testing
PDF
Standford 2015 week3: Objective-C Compatibility, Property List, Views
PDF
OpenXR 1.0 Reference Guide
PPT
Advance features of C++
SANER 2019 Most Influential Paper Talk
Dynamic C++ ACCU 2013
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Microsoft Word Hw#1
Dynamic C++ Silicon Valley Code Camp 2012
Ds 2 cycle
C programs
Asssignment2
Standford 2015 week9
The Ring programming language version 1.8 book - Part 65 of 202
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
The Ring programming language version 1.6 book - Part 62 of 189
Advance java
Javascript & Ajax Basics
An introduction to thrust CUDA
Property-based testing
Standford 2015 week3: Objective-C Compatibility, Property List, Views
OpenXR 1.0 Reference Guide
Advance features of C++
Ad

Similar to Encoder + decoder (20)

PDF
Dsp lab manual
DOC
Digital Signal Processing Lab Manual
DOCX
Digital Signal Processing and Control System under MATLAB Environment
PDF
Actividad #7 codigo detección de errores (yango colmenares)
PDF
Matlab 3
PDF
dsp.pdf
PDF
Multirate sim
DOCX
Signals And Systems Lab Manual, R18 Batch
PDF
Matlab workshop
DOCX
signal and system
PDF
Matlab task1
PDF
Matlab kod taslağı
PPTX
DIGITAL_SIGNAL_AND_IMAGE_PROCESSING_USIN.pptx
PDF
Dsp file
PDF
Digital Signal Processing
DOCX
Basic simulation lab manual1
PDF
Introduction to Matlab for Engineering & Science Students.pdf
PDF
Summer training matlab
PDF
Matlab for beginners, Introduction, signal processing
PPTX
Summer training matlab
Dsp lab manual
Digital Signal Processing Lab Manual
Digital Signal Processing and Control System under MATLAB Environment
Actividad #7 codigo detección de errores (yango colmenares)
Matlab 3
dsp.pdf
Multirate sim
Signals And Systems Lab Manual, R18 Batch
Matlab workshop
signal and system
Matlab task1
Matlab kod taslağı
DIGITAL_SIGNAL_AND_IMAGE_PROCESSING_USIN.pptx
Dsp file
Digital Signal Processing
Basic simulation lab manual1
Introduction to Matlab for Engineering & Science Students.pdf
Summer training matlab
Matlab for beginners, Introduction, signal processing
Summer training matlab
Ad

More from COMSATS Abbottabad (20)

PDF
Kalman filter
PDF
Enterpreneurship
PPTX
Sine wave inverter
PPTX
Light Tracking Solar Panel
PDF
Analysis of Electro-Mechanical System
PDF
coding and burning program in FPGA
PDF
8 bit full adder
PDF
Fabrication process of Integrated Circuit (IC's)
DOCX
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
PDF
implementation of data instrucions in emu8086
PDF
Addition, subtraction and multiplication in assembly language
PDF
Mathematical Modelling of Electro-Mechanical System in Matlab
PDF
Mathematical Modelling of Electrical/Mechanical modellinng in MATLAB
PDF
Introduction to MATLAB
PDF
Principles of Communication
PDF
Aurduino coding for transformer interfacing
PDF
Transformer Interfacing with Laptop
PDF
Temperature control Switch and Display By Led
PPTX
stress and strain
PDF
Generating PM wave
Kalman filter
Enterpreneurship
Sine wave inverter
Light Tracking Solar Panel
Analysis of Electro-Mechanical System
coding and burning program in FPGA
8 bit full adder
Fabrication process of Integrated Circuit (IC's)
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
implementation of data instrucions in emu8086
Addition, subtraction and multiplication in assembly language
Mathematical Modelling of Electro-Mechanical System in Matlab
Mathematical Modelling of Electrical/Mechanical modellinng in MATLAB
Introduction to MATLAB
Principles of Communication
Aurduino coding for transformer interfacing
Transformer Interfacing with Laptop
Temperature control Switch and Display By Led
stress and strain
Generating PM wave

Recently uploaded (20)

PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
OOP with Java - Java Introduction (Basics)
PDF
composite construction of structures.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
PPT on Performance Review to get promotions
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
DOCX
573137875-Attendance-Management-System-original
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Construction Project Organization Group 2.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
CYBER-CRIMES AND SECURITY A guide to understanding
OOP with Java - Java Introduction (Basics)
composite construction of structures.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPT on Performance Review to get promotions
UNIT 4 Total Quality Management .pptx
additive manufacturing of ss316l using mig welding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
573137875-Attendance-Management-System-original
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS

Encoder + decoder

  • 1. Syed Abuzar Page 1 Encoder and Decoder using MATLAB If u want help regarding this feel free to contact 03129926454 1st Program: function varargout = Decodeeer(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Decodeeer_OpeningFcn, ... 'gui_OutputFcn', @Decodeeer_OutputFcn, ... 'gui_LayoutFcn', [] , ...
  • 2. Syed Abuzar Page 2 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end function Decodeeer_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; guidata(hObject, handles); function varargout = Decodeeer_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function one_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=697; f_high=1209; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H));
  • 3. Syed Abuzar Page 3 title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); %it is function which store the input from a function and it can be used in other functions. y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function two_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=697; f_high=1336; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid;
  • 4. Syed Abuzar Page 4 x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function three_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=697; f_high=1477; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N);
  • 5. Syed Abuzar Page 5 H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function four_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=770; f_high=1209; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid;
  • 6. Syed Abuzar Page 6 xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function five_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=770; f_high=1336; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r)
  • 7. Syed Abuzar Page 7 function six_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=770; f_high=1477; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function seven_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1;
  • 8. Syed Abuzar Page 8 N=5000; f_low=852; f_high=1209; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function eight_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=852; f_high=1336; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t);
  • 9. Syed Abuzar Page 9 y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function nine_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=852; f_high=1477; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N);
  • 10. Syed Abuzar Page 10 H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function staric_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=941; f_high=1209; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)');
  • 11. Syed Abuzar Page 11 ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function zero_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=941; f_high=1336; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); %it is function which store the input from a function and it can be used in other functions.
  • 12. Syed Abuzar Page 12 y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2); plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function hash_Callback(hObject, eventdata, handles) clc fs=8000; t=0:1/fs:0.1; N=5000; f_low=941; f_high=1477; y1=sin(2*pi*f_low*t); y2=sin(2*pi*f_high*t); y=y1+y2; wavplay(y,fs); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y,N)); axes(handles.axes1); plot(w,abs(H)); title('DTMF Input');xlabel('f(Hz)'); ylabel('Amplitude');grid; x=getappdata(0,'Noise'); y1=awgn(y,x); w=linspace(-fs/2,fs/2,N); H=fftshift(fft(y1,N)); axes(handles.axes2);
  • 13. Syed Abuzar Page 13 plot(w,abs(H), 'r'); title('FFT ');grid; xlabel('f(Hz)');ylabel('Amplitude'); r=filtered(y1); disp(r) function noise_Callback(hObject, eventdata, handles) x=str2double(get(handles.noise, 'String' )); setappdata(0,'Noise',x); function noise_CreateFcn(hObject, eventdata, handles) if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function info_Callback(hObject, eventdata, handles) msgbox('File was created by : Syed Abuzar Comsats Abbottabad Reg # SP15-BEE-096 Submitted To : Mam Rabya','Info','warn') function Close_Callback(hObject, eventdata, handles) close; 2nd Program: function output = filtered(y) fs=8000; N=5000; Hd1=lowpass_filter; x1=filter(Hd1,y); x1 = fft(x1,N); [~,m1] = max(abs(x1));
  • 14. Syed Abuzar Page 14 m1=m1*1.6; % disp('max1') % disp(m1) Hd2=highpass_filter; x2=filter(Hd2,y); x2 = fft(x2,N); [~,m2] = max(abs(x2)); m2=m2*1.6; % disp('max2') % disp(m2) % L=[697,770,852,941]; % H=[1209,1336,1477]; if ((m1>692) && (m1<720)) m1=697; elseif ((m1>765) && (m1<800)) m1=770; elseif ((m1>847) && (m1<880)) m1=852; elseif ((m1>936) && (m1<960)) m1=941; end % disp(m1) if ((m2>1204) && (m2<1240)) m2=1209; elseif ((m2>1331) && (m2<1360)) m2=1336; elseif ((m2>1472) && (m2<2500)) m2=1477; end
  • 15. Syed Abuzar Page 15 % disp(m2) j=m1; k=m2; if j<=697 & k<=1209; key = '1'; elseif j<=697 & k<=1336; key = '2'; elseif j<=697 & k<=1477; key = '3'; elseif j<=770 & k<=1209; key = '4'; elseif j<=770 & k<=1336; key = '5'; elseif j<=770 & k<=1477; key = '6'; elseif j<=852 & k<=1209; key = '7'; elseif j<=852 & k<=1336; key = '8'; elseif j<=852 & k<=1477; key = '9'; elseif j<=941 & k<=1209; key = '*'; elseif j<=941 & k<=1336; key = '0'; elseif j<=941 & k<=1477; key = '#'; else key= 'very noisy signal' ; end output=key; end
  • 16. Syed Abuzar Page 16 3rd Program: function Hd = lpfilter ]Fs = 8000; % Sampling Frequency Fpass = 980; % Passband Frequency Fstop = 1000; % Stopband Frequency Dpass = 0.99980002; % Passband Ripple Dstop = 0.0001; % Stopband Attenuation dens = 20; % Density Factor % Calculate the order from the parameters using FIRPMORD. [N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]); % Calculate the coefficients using the FIRPM function. b = firpm(N, Fo, Ao, W, {dens}); Hd = dfilt.dffir(b); % [EOF] 4rth Program: function Hd = highpass_filter Fs = 8000; % Sampling Frequency Fstop = 1100; % Stopband Frequency Fpass = 1130; % Passband Frequency Dstop = 0.0001; % Stopband Attenuation Dpass = 0.99980002; % Passband Ripple dens = 20; % Density Factor
  • 17. Syed Abuzar Page 17 % Calculate the order from the parameters using FIRPMORD. [N, Fo, Ao, W] = firpmord([Fstop, Fpass]/(Fs/2), [0 1], [Dstop, Dpass]); % Calculate the coefficients using the FIRPM function. b = firpm(N, Fo, Ao, W, {dens}); Hd = dfilt.dffir(b); % [EOF]