Project Report PDF
Project Report PDF
GROUP MEMBERS
Muzammil Faisal 200278
Arham Tahir 200296
Syed Asghar Raza 200314
Abdullah Saleh 200330
Class:- BEEP-4B
Submitted To:
1|CEA
GUI Signal Calculator
Contents
CHAPTER-1 .................................................................................................................................. 3
What is GUI? ................................................................................................................................. 3
1. Components: .......................................................................................................................... 3
3. Callbacks: ............................................................................................................................... 4
What is GUIDE? ........................................................................................................................... 4
Aim: ................................................................................................................................................ 4
CHAPTER-2 .................................................................................................................................. 4
Architecture: ................................................................................................................................. 4
Advantages: ................................................................................................................................... 5
Applications:.................................................................................................................................. 5
Continuous Time Signals: ............................................................................................................ 5
Discrete-time signal: ..................................................................................................................... 6
Convolution: .................................................................................................................................. 7
Convolution in MATLAB: ........................................................................................................... 7
Convolution of Continuous-Time Signals:.................................................................................. 7
Convolution of Discrete-Time Signals: ....................................................................................... 8
Fourier Series: ........................................................................................................................... 8
Fourier Transforms: ..................................................................................................................... 8
CHAPTER-3 .................................................................................................................................. 9
CHAPTER-4 ................................................................................................................................ 15
Graphical Results: ...................................................................................................................... 15
3. Continuous Signal Plotting: ......................................................................................................... 16
4. Discrete Signal Plotting: ............................................................................................................... 16
5. Convolving Signal: ........................................................................................................................ 17
6. Fourier Series: ............................................................................................................................... 17
7. Fourier Transform: ...................................................................................................................... 18
CHAPTER-5 ................................................................................................................................ 19
2|CEA
ABSTRACT: -
In this era, where everyone is looking to perform operations which are time saving and consumes
less energy and performs the task in quick manner more efficiently. So with MATLAB GUI, we can
easily perform any task just by pressing buttons because every operation is linked with its button that
performs it. With the help of signal calculator, we can easily solve any problem and generate signals such
as Fourier transform, Fourier series and Laplace transform. We can also use GUI for visualization of
images.
CHAPTER-1
Introduction:
What is GUI?
The main aim of the project is to design a signal calculator in Matlab using GUI. GUI
also known as graphical user interference, provide point and click control of software applications,
eliminating the need to learn a language or type commands in order to run the applications. To
perform these tasks, the user of the GUI does not have to create a script or type commands at the
command line. Often, the user does not have to know the details of the task at hand. The GUI
components can be menus, toolbars, push buttons, radio buttons, list boxes, and sliders, just to
name a few. In MATLAB, a GUI can also display data in tabular form or as plots and can group
related components.
An axes component
Four edit texts
Five static texts
Six buttons.
The following are the principal components required to create a MATLAB GUI:
1. Components:
Each element on MATLAB GUI (pushbuttons, labels, edit boxes, etc.) is a graphical
component. The method of components includes graphical controls (pushbutton, toggle
button, edit boxes, files, sliders, etc.) static components (text boxes), menus, toolbars, and
axis.
2. Containers:
The components of GUI must be organized within a container, which is a window on
the computer screen. The most common container is a figure. A figure is a window on the
laptop screen that has a little title bar along the top, and that can optionally have menus
connect.
3|CEA
3. Callbacks:
If a user clicks on a button, then that event must cause the Matlab code that
implements the role of the button to be executed. The code performed in response to an
event is known as callback. There must be a call back to implement the role of graphical
element in GUI.
What is GUIDE?
GUIDE, the MATLAB graphical user interface development environment, provides a set
of tools for creating graphical user interfaces (GUIs). These tools simplify the process of
lying out and programming GUIs.
Aim:
This project will assist in the plotting of discrete and continuous signal graphs. By simply
entering data into the text boxes, the user can check the results. It takes less time to
complete. Convolution, Fourier series representation, and Fourier transformations are
among the additional functionalities provided by the project. For someone who is new to
this topic, the difficulties relating to these theorems are far too time-consuming and tough.
However, the outcome may be quickly verified by plugging in the signal expression and
other factors such as frequency and time. The calculated result will be presented in the
command window, and the graph will be displayed in the axis.
CHAPTER-2
Architecture:
We need a signal calculator on MATLAB using GUI that can:
1. Plot the signals in both discrete time and continuous time domains.
2. Convolve any two signals.
3. Display Fourier series and Fourier Transform of Signals.
Flow Chart:
4|CEA
Advantages:
Following are the advantages of using GUI:
The advantage of signal calculator using MATLAB GUI is that we can easily plot any
graph just using commands and solve any Fourier series or any other series easily in it. It
is time efficient and saves a lot of time and energy.
Since data is represented by symbols, shapes and icons, users can easily recognize, classify
and navigate options.
Easy Understanding. Visual Representation of data is recognized faster than text.
GUI lets users take advantage of shortcut keys to minimize strokes. A combination of
several actions saves the user time and increase productivity.
GUI lets users to work and view two or more programs at the same time.
A GUI is much appealing as compared to command line interface, the GUI is more stylish
and elegant in their design.
GUI’S generally provide users with immediate, visual feedback about the effect of each
action.
Searching becomes very easy as GUI provides a visual representation of files present and
provides details about.
We can solve any mathematical problem using GUI.
Applications:
Following are its applications:
The "function of a continuous-time variable with an uncountable or infinite set of numbers in its
sequence" is referred to as a continuous-time signal. At each point in time in its sequence, the
continuous-time signal can be expressed and characterized. The analogue signal is also known as
a continuous-time signal. It's a time-dependent continuous function defined on the real line (or
axis) R. It has a constant amplitude and duration. That is, at any point in time, continuous-time
signals will have a specific value.
5|CEA
Sine waves, cosine waves, triangle waves, and other continuous-time signals are examples.
When electrical signals are derived in proportion to physical characteristics such as pressure,
temperature, sound, and so on, they behave like continuous-time signals.
Discrete-time signal:
The "function of a discrete-time variable that has a countable or finite set of numbers in its
sequence" is referred to as a discrete-time signal. It's a representation of a continuous-time signal
in digital form. At specific points in time in its sequence, the discrete-time signal can be
expressed and characterized. That is, the sampling instants are the only places where the discrete-
time signal may be defined. By quantizing and encoding the sample values, a digital signal can
be created from a discrete-time signal. Binary bits are used to represent discrete-time signals,
which are then stored on a digital medium.
6|CEA
One example of discrete-time signals is the data output from a computer. Some of the examples
of discrete time signals in MATLAB
Convolution:
Convolution in MATLAB:
The built-in MATLAB function 'conv' convolves LTI systems and returns the result of the
convolution. The convolution of the vectors x and h is returned by y = conv(x,h). The length of
the generated vector is:
Because convolution is commutative, the results of convolving 'x' with 'h' or 'h' with 'x' will be
similar.
Convolution is represented by the symbol *. The computation of an integral is required for the
convolution of two continuous-time signals. The integral of convolution is written as:
7|CEA
Convolution of Discrete-Time Signals:
The steps for convolution of discrete-time signals are largely the same as for continuous-time
signals. Assume y[n] is the system's output, x[n] is the input signal, and h[n] is the system's
impulse response. The convolution relationship is mathematically expressed as:
Fourier Series:
The sum of sine and cosine functions is used to represent a periodic function in a Fourier series.
It's a periodic function made up of harmonically linked sinusoids that are added together using a
weighted summation. One cycle of the summing can be used to approximate an arbitrary
function in that interval with the right weights. Instead of expressing the signal amplitude as a
function of time, the Fourier series depicts the signal in terms of how much information is
contained at various frequencies.
or
Fourier Transforms:
The Fourier Transform is a mathematical technique that converts a time function, x(t), into a
frequency function, X. (w). The Fourier Series and the Fourier Transform are closely connected.
The Fourier Series can only be used on periodic signals. Fourier devised a mathematical model
to transfer signals from time domain to frequency domain and vice versa to describe aperiodic
signals, which is known as the 'Fourier transform.'
8|CEA
CHAPTER-3
Source Code:
function varargout = untitled1(varargin) % Default generate by GUI
% UNTITLED1 MATLAB code for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input
arguments.
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises
the
% existing singleton*. Starting from the left, property value pairs
are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to untitled1_OpeningFcn via varargin.
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled1
% Last Modified by GUIDE v2.5 27-May-2022 19:49:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1; % Default generate by GUI
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'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
% End initialization code - DO NOT EDIT
% --- Executes just before untitled1 is made visible.
function untitled1_OpeningFcn(hObject, eventdata, handles, varargin) %
Default generate by GUI
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled1 (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
9|CEA
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_OutputFcn(hObject, eventdata, handles) %
Default generate by GUI
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in mean.
function mean_Callback(hObject, eventdata, handles) % We use this for the
different required functions
% hObject handle to mean (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns mean contents as
cell array
% contents{get(hObject,'Value')} returns selected item from mean
val=get(handles.mean,'value');
switch(val) % Second case for continuous
case 2
a=get(handles.edit5,'string'); % For display
t=0:0.01:10; % Time interval
x=0:0.01:10;
axes(handles.axes3) % For Showing
plot(eval(a)) % For plot
axis([-5 length(t) -2 2]) % By giving x and y-axis
title('continuous Time Signal') % By writing Title
xlabel('t(x)') % By labeling x-axis
ylabel('y(x)') % By labeling y-axis
grid on % For displaying lines
case 3 % Third case for discrete
b=get(handles.edit5,'string'); % For display
n=0:1:50;
t=0:1:10; % Time interval
axes(handles.axes3) % For Showing
stem(eval(b)) % For plot
axis([-5 length(n) -2 2])
axis([-5 length(t) -2 2])
title('Discrete Time Signal') % By writing Title
xlabel('t(x)') % By labeling x-axis
ylabel('y(x)') % By labeling y-axis
grid on % For displaying lines
case 4 % Fourth case for convolution
t=0:0.5:10;
y=0:0.5:10;
h = get(handles.edit4,'string'); % For display
n = get(handles.edit5,'string'); % For display
axes(handles.axes1) % For showing
plot(eval(n)); % For plot
hold on
axis([-5 length(t) -2 2]) % By giving x and y-axis
plot(eval(h)); % For plot
axis([-5 length(t) -2 2]) % By giving x and y-axis
title('Original Signals') % By writing Title
xlabel('t(x)') % By labeling x-axis
10 | C E A
ylabel('y(t)') % By labeling y-axis
hold on
grid on % For displaying lines
b = conv(eval(n),eval(h)); % For convoluution
n1=1:length(b);
axes(handles.axes3) % For showing
plot(n1,b); % For plot
hold on
title('Convolution Signal') % By writing Title
xlabel('t(x)') % By labeling x-axis
ylabel('x(t)*h(t)') % By labeling y-axis
grid on % For displaying lines
case 5 % Fifth case for Fourier Series
a=get(handles.edit5,'string'); % For display
a=str2num(a)
t=-5:0.01:5; % For Time Interval
axes(handles.axes1) % For showing
s = square(2*pi*t,50); % Function for square wave
wO = 2*pi; % Frequency
plot(t,s,'b','Linewidth',2) % Plotting original square wave
grid on % By showing lines on the graph
title('Original Square Wave') % By writing Title
axis([-5 5 -2 2]) % By specifying x and y axis
K = [a];
for N = 1:length(K) % By starting from 1 and ranges to K
k = 1:2:K(N);
x = (4./(pi*k)) * sin(wO*k'*t); % BY Default giving function
axes(handles.axes3) % For showing
plot(t,s,'k','Linewidth',2) % For plot
hold on % For delay
axes(handles.axes3) % For showing
plot(t,x,'m','Linewidth',2) % For plot
hold off % For no delay
axis([-1 5 -2 2]) % By specifying x and y-axis
grid on % By showing lines on the graph
title(['Fourier Series representation with',... %title,number
num2str(K(N)),' harmonics']);
end
case 6 % Sixth case for Fourier Transform
syms t % By initializing variable
t=-1:0.1:5; % Time Interval
x=get(handles.edit5,'string'); % Taking Function
axes(handles.axes1) % For Display Input
ezplot(x) % For plot
title('Original Signal') % By writing Title
grid on % By showing lines
xlabel('t') % By labeling x-axis
ylabel('x(t)') % By labeling y-axis
axes(handles.axes3) % For display Output
x = inline(vectorize(get(handles.edit5,'string'))); % For observing
FFT = abs(fftshift(fft(x(t)))); % By taking Fourier Transform
plot(FFT) % For ploting fourier Transform
title('Fourier Transform') % By writing Title
grid on % By showing lines
otherwise
c='option invalid'
end
11 | C E A
%set(handles.edit5,'string',c)
% --- Executes during object creation, after setting all properties.
function mean_CreateFcn(hObject, eventdata, handles) % Default generate for
different functions
% hObject handle to mean (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in discrete.
function discrete_Callback(hObject, eventdata, handles) % For Continuous
Function
% hObject handle to discrete (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%discrete time
b=get(handles.edit5,'string'); % For display
b=get(handles.edit4,'string'); % For display
n=0:1:50;
t=0:1:50;
axes(handles.axes3) % For showing
stem(eval(b)) % For plot
axis([-1 length(n) -2 2]) % By specifying x and y-axis
axis([-1 length(t) -2 2])
title('Discrete Time Signal') % By writing title
xlabel('t(x)') % By labeling x-axis
ylabel('y(x)') % By labeling y-axis
grid on % By showing lines on graph
% --- Executes on button press in plot.
function plot_Callback(hObject, eventdata, handles) % Function for plot
% hObject handle to plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a=get(handles.edit4,'string'); % For display
t=0:0.1:10;
x=0:0.1:10;
axes(handles.axes1) % For showing
plot(eval(a)) % For plot
title('Continuous Time Signal') % By writing title
xlabel('t(x)') % By labeling X-axis
ylabel('y(x)') % By labeling y-axis
grid on %By showing lines on graph
% Hint: get(hObject,'Value') returns toggle state of plot
% --- Executes on button press in clear.
function clear_Callback(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit4,'string',''); % For clearing input1
set(handles.edit5,'string',''); % For clearing input2
cla(handles.axes1); % For clearing axis1
cla(handles.axes3); % For clearing axis3
clear all % For clearing all
12 | C E A
clc
% Hint: get(hObject,'Value') returns toggle state of clear
% --- Executes on button press in compare.
function compare_Callback(~, ~, ~) % For ON/OFF Function
% hObject handle to compare (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all
% Hint: get(hObject,'Value') returns toggle state of compare
function edit4_Callback(hObject, eventdata, handles) % For INPUT 1 FUNCTION
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a
double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles) % For INPUT 1 FUNCTION
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles) % For INPUT 2 FUNCTION
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a
double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles) % For INPUT 2 FUNCTION
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in continuous.
function continuous_Callback(hObject, eventdata, handles)
% hObject handle to continuous (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%continuous time
a=get(handles.edit5,'string'); % For display
a=get(handles.edit4,'string');
t=0:0.01:10;
y=0:0.01:10;
axes(handles.axes3) % For showing
plot(eval(a)) % For plot
13 | C E A
axis([-5 length(t) -2 2])
title('Continuous Time Signal') % By writing title
xlabel('t(x)') % By labeling x-axis
ylabel('y(x)') % By labeling y-axis
grid on % By showing lines on graph
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over text6.
function text6_ButtonDownFcn(hObject, eventdata, handles) % For label 1-
INPUT
% hObject handle to text6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit6_Callback(hObject, eventdata, handles) % For left border
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a
double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles) % For left border
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles) % For right border
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a
double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles) % For right border
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
14 | C E A
CHAPTER-4
Graphical Results:
1. GUI Interface:
15 | C E A
3. Continuous Signal Plotting:
16 | C E A
5. Convolving Signal:
6. Fourier Series:
7.
17 | C E A
7. Fourier Transform:
18 | C E A
CHAPTER-5
Conclusions:
This semester's project encapsulates everything we've learned in Signals and Systems, both in
theory and in the lab. For charting, convolving, and visualizing Fourier series and transforms, we
created a "Signal Calculator." In today's competitive world, where every second counts, this
calculator saves us time by automatically doing difficult calculations for visualizing various time
signals, such as Continuous and Discrete Time Signals. We employed a MATLAB GUI system in
this project, where we used MATLAB scripts to construct a simple and usable GUI system for our
users. We'd discovered something new that how to use MATLAB to develop simple and
sophisticated routines, how to create and deploy a user-friendly graphical user interface and how
to put the knowledge we learned in the course to good use and put it into practice.
References:
1. For flowcharts
https://dashboard.visme.co/v2/projects/own
2. For research
https://www.mathworks.com/help/matlab/
19 | C E A