Professional Documents
Culture Documents
MADHAVILATHA
183002110
AIM:
To analyse the spectrum of a signal using DFT using MATLAB.
PROCEDURE:
1.Open MATLAB and open GUIDE by typing ‘guide’ in the command window.
2.Open new UI in the GUIDE layout editor.
3.Display the names of UI component in the palette.
4.set the window size in GUIDE.
5.Layout the simple GUIDE UI.
6.Add necessary components to the UI as per the requirements.
7.Align the components and label them appropriately.
8.Save the UI layout.
9.Code the behaviour of the GUIDE layout by adding the desired m-code to the
call back functions.
10.Save the UI layout and the m-code with the same file name.
11.Run either .m file or .fig file.
12.Verify the output.
P.MADHAVILATHA
183002110
M-CODE:
To compute DFT of a signal using MATLAB, FFT algorithm is used.
ANALYSIS 1: SPECTRUM OF COMPOSITE SIGNAL
function varargout = ex441(varargin)
% EX441 MATLAB code for ex441.fig
% EX441, by itself, creates a new EX441 or raises the existing
% singleton*.
%
% H = EX441 returns the handle to a new EX441 or the handle to
% the existing singleton*.
%
% EX441('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EX441.M with the given input arguments.
%
% EX441('Property','Value',...) creates a new EX441 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ex441_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ex441_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
'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
% --- Outputs from this function are returned to the command line.
function varargout = ex441_OutputFcn(hObject, eventdata, handles)
% 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)
P.MADHAVILATHA
183002110
n1=0:99;
y=sin(2*pi*n1*f1/8000)+sin(2*pi*n1*f2/8000);
plot(handles.axes3,n1,y,'k');
axes(handles.axes3);
xlabel('time');ylabel('magnitude');title('composite signal');axis tight
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = exp442_OutputFcn(hObject, eventdata, handles)
% 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)
set(hObject,'BackgroundColor','white');
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = ex53_OutputFcn(hObject, eventdata, handles)
% 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)
OUTPUT:
INFERENCE:
1.The spectrum of a periodic composite signal is discrete and the frequency
components are clearly visible in the magnitude spectrum plot.
2.The spectrum of a noisy signal is also noisy. However, the frequency
components of the signal are visible in the magnitude spectrum plot. This may
become invisible if voice level increases.
3.The spectrum of a voice is continuous, containing a band of frequencies. The
maximum frequency component in the voice is approximately 4000 Hz. The
strength of the magnitude decrease in the upper end of spectrum.
RESULT:
Thus the spectrum analysis of signals is performed using MATLAB,
displayed using GUIDE and the outputs are verified.