Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application...

17
Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface components Practice building callback functions that display data and manipulate the GUI This will be a step-by-step design procedure 1 GUIDE Tutorial

Transcript of Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application...

Page 1: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial1

Introduction to Matlab & Data Analysis 2015

In this tutorial we will:• Build a practical application using GUIDE• Learn more about graphical user interface components• Practice building callback functions that display data and manipulate

the GUI• This will be a step-by-step design procedure

Page 2: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial2

1. Open a blank template in GUIDE2. Open the Preferences dialog and toggle the “Show names” option

Page 3: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial3

3. Add a push button4. Duplicate this button 2 times to create 3 buttons

Page 4: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial4

5. Add a panel to contain our buttons. Move the buttons on to the panel.6. Add an axis for the surface plot

Adjust the window size by moving this corner

Page 5: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial5

7. You can align and distribute components

Page 6: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial6

8. Open the Properties Inspector of each push button and change the String and the Tag

Page 7: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial7

9. Using the Properties Inspector, edit the options string for the pop-up menu10. At this point you can activate the GUI , this will generate an *.m file and a *.fig file

Page 8: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial8

11. We will now go to the opening function which is called when the GUI starts

* To share data between the GUI objects we use the handles structure which is passed between functions

Page 9: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial9

12. Here we will define three datasets and create and initial plot

* To share data between the GUI objects we use the handles structure which is passed between functions

Page 10: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial10

13. Now we will edit the callback functions of the pushbuttons to update the 2D plotting method

handles.current_data stores our current dataset

Page 11: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial11

14. And finally we need to update the callback of the pop-up menu to update the right dataset

Don’t forget to update the handles structure using the function guidata()

Page 12: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial12

15. Now your GUI should be fully functional. You can activate it from the editor, layout editor or the command line

Page 13: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial13

1. Create a new GUI layout called ‘slider’ . This GUI will slide to the right MRI slice

Page 14: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial14

2. In the opening function, load the MRI data and display the first slice

Page 15: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial15

3. In the slider callback function we shall calculate the requested frame number and display it

Page 16: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial16

4. Try to slide through the axial slices of the dataset

Page 17: Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.

GUIDE Tutorial17

5. Now let’s display the current slice number in the static text

set(handles.frame_num,'string',num2str(handles.current_frame));guidata(hObject, handles);