You are on page 1of 31

Development and Implementation of GUI using MATLAB for Fast Fourier Transformation

Presented by: Binayak Ojha

Date: 09.05.2013

1. Motivation 2. Objectives 3. Discrete Fourier Transform (DFT) 4. Fast Fourier Transform (FFT) 5. Windowing 5.1 Rectangular Window 5.2 Hamming Window 5.3 Hanning Window 6. Some MATLAB Functions 7. GUI-control Elements 8. GUI-control Elements Properties 9. GUIDE

9.1 Layout Editor 9.2 Property Inspector 9.3 Object Browser 9.4 Menu Editor 10. GUI Layout Design 11. Algorithm for designed GUI 12. Use of CallBack Function 13. MATLAB code for FFT 14. Output Snapshots 15. Conclusion References

Need of some simulations for demonstration.

To develop and implement GUI for FFT Other requirements 1.Two separte plots for input and output signal. 2.Cosine signal as input signal. 3.Frequency spectrum of FFT of input as output. 4.Demonstration of leakage effect. 5.Windowing demonstration 6.Sliders to change input and output signal characteristics.

A signal can be collection of frequency components. Extracts the signal component F() at frequency Mathematically represented as,

f[k] : discrete signal N: Number of samples

Algorithm to calculate DFT fast and efficiently. First published in 1965 by Cooley and Tuckey. Applies only to signals with elements 2m. FFT returns set of complex numbers. But, real numbers for f=0 and f= fs /2.

Output spectrum of DFT has spectral leakage. Windowing minimize spectal leakage. DFT of x[i]w[i] is done. Different types of window functions available. 1.Rectangular Window 2.Hanning Window 3.Hamming Window

W[n] = 1 =0

for n N for n > N


^

Figure 1 : Cosine Signal in Rectangular Window

W[n] = 0.5- 0.5 cos =0

for n N for n > N

Figure 2: Cosine Signal in Hanning Window

W[n] = 0.53836 - 0.46164 cos =0

for n N for n > N

Figure 3: Cosine Signal in Hamming Window

Y = fft(x) returns the DFT of vector x, [2]. w = hamming(L) returns an L-point symmetric Hamming window in the column vector w, [2]. w = hann(L) returns an L-point symmetric Hann window in the column vector w, [2].

Table 1: MATLAB GUI-Control Elements [4]


S.N 1 2 3 4 5 6 7 8 9 10 UI Control Check Box Editable Text Frame Pop-up Menu List Box Push Button Radio Button Toggle Button Slider Static Text Style Value checkbox edit frame popup listbox pushbutton radio toggle slider text Description Indicates the states of an option User editable text box Used to group the controls Provides the list of options Shows scrollable list of options Invokes an event immediately Indicates selectable options Two states, ON or OFF Represents a range of values Displays a string in a box

Table 2a:GUI-Control Elements Properties [4]


S.N. 1 2 3 4 5 6 7 Property BackgroundColor ButtonDownFcn CData CallBack Enable Extent FontAngle S.N. 8 9 10 11 12 13 14 Property FontName FontSize FontUnits FontWeight ForegroundColor HorizontalAlignment Interruptible

Table 2b: GUI-Control Elements Properties [4]


S.N. 15 16 17 18 19 20 21 Property S.N. 22 23 24 25 26 27 28 Property

ListBoxTop Max Min Position String Style SliderStep

TooltipString Units UIContextMenu Value Tag UserData Visible

Stands for GUI Development Enviornment MATLAB tool to create GUI Easy to use Components of GUIDE 1.Layout Editor 2.Property Inspector 3.Object Browser 4.Menu Editor

Figure 4: GUIDE Layout Editor

Figure 5: GUIDE Property Inspector

Figure 6: GUIDE Object Browser

Figure 7: GUIDE Menu Editor

Figure 8: GUI Layout

Step 1: Start Step 2: Set the value of slider 1, slider 2, slider 3 and slider 4 to zero. Step 3: Reset Hanning and Hamming Window. Step 4: Compute FFT length using slider 4 value and show in edit text box 4. Step 5: Set the rectangular window. Step 6: Show slider 1, slider 2, and slider 3 values in edit text box 1, edit text box 2 and edit text box 3 respectively. Step 7: Compute FFT length using slider 4 value and show in edit text box 4.

Step 8: Compute input signal array for currently active window and current sliders values. Step 9: Compute FFT and output signal array. Step 10: Plot input signal in axes 1 and output signal in axes 2. Step 11: If slider 1 or slider 2 or slider 3 or slider 4 has new value then go to step 4. Step 12: If edit text box 1 or edit text box or edit text box 3 or edit text box 4 have new value, set the value of respective slider. Go to step 6. Step 13: If Hanning window is set, reset the hamming window and rectangular window.

Go to step 8. Step 14: If Hamming window is set, reset the hanning window and rectangular window. Goto step 8. Step 15: If hanning and hamming both are reset, compute rectangular window vector. Goto step 8. Step 16: Stop

An important property of a GUI Element Indicates actions to be performed when activated


function slider1_Callback(hObject, eventdata, handles) set(handles.edit3,'string',(int32(get(handles.slider1,'value')))); my_task(get(handles.slider1,'value'),get(handles.slider3,'value'),get(ha ndles.slider6,'value'),get(handles.slider7,'value')); Figure 9: Implementation of Callback Function

k=fft_length(s3) ; % function fft_length() returns number of fft points if k >1 fftval=fft(x,k); % calculate array of fft for k points indexnyquist=(k/2)+1; %centre FFT point fftval=fftval(1:indexnyquist); %truncate the negative parts k=cast(k,'double'); fftval=fftval/k; %scale %whos k fftval(2:end)=2*fftval(2:end); %compensate for truncating df=fs/k ; %discrete frequency interval frequency_axis=(0:indexnyquist-1)*df; %array of frequency to plot magnitude=abs(fftval); % magnitude of spectrum plot_output(frequency_axis,magnitude); % plot the fft in frequency spectrum

Figure 10: Implementation of FFT

Figure 11: Output snapshot 1

Figure 12: Output snapshot 2

GUIDE is a good tool for GUI designing. GUI for FFT was developed and implemented. GUI for other complex processes can be developed.

1.www.mathworks.de/academia/student_center/tutorials 2.www.mathworks.com 3.Discrete Time Signal Processing, Second Edition, Allan V Oppenheim 4.Graphics and GUIs with MATLAB, Third Edition, Patrick Marchand & O. Thomas Holland

You might also like