This document provides an introduction and overview of MATLAB and GUI development in MATLAB. It covers key topics such as the MATLAB screen and interface, variables and arrays, vector and matrix generation and operations, flow control and loops, functions, and building GUI applications using GUIDE and callbacks. It also provides some useful tips for working with images and dialog boxes in MATLAB GUIs.
2. INTRODUCTION
MATLAB stands for Matrix Laboratory.
MATLAB had many functions and toolboxes
Integration
Image Processing
Linear Algebra
…
Is high level language
Solves computing problems
in a fraction of the time
2
3. MATLAB SCREEN
Command Window
type commands
Current Directory
View folders and m-files
Workspace
View program variables
Double click on a variable
to see it in the Array Editor
Command History
view past commands
save a whole session
using diary
3
4. VARIABLE
No need for types
int a = 10;
float pie = 3.1415;
All variable are of double precision unless specified
pie = 3.1415
s = 123
All variable are 1x1 matrices
4
5. ARRAY
a vector
x = [1 2 5 1]
x = 1 2 5 1
a matrix
x = [1 2 3; 5 1 4; 3 2 -1]
transpose
y = x’
5
11. FUNCTIONS
No return keyword
function out1=fname(in1,in2,in3)
Some commands
function [out1,out2]=name(in1,in2)
EXAMPLE
function [out1, out2] = sumprod(array)
out1 = sum(array)
out2 = prod(array)
11
12. GUI APPLICATION
Starting new App
Home > New > App > GUIDE
Home > New > App > App Designer
GUIDE
Procedural
App Designer
Object Oriented
Both have same components
12
15. CALLBACK
Catchable event of Button
Callback (OnClick)
Create –When button is created
Delete – button is delete
ButtonDown
KeyPress
Execute when event/callback occur
Jumps to that code
15
16. COMPONENT INSPECTOR
• Set String Property of Button
• set(handles.pushbutton1,‘String',‘test');
• Get String Property of Button
• get(handles.pushbutton1,‘String');
16
17. SOME USEFULTIPS
Open Dialog Box
[filename,pathname] = uigetfile('*.bmp;','Select bmp file');
Save Dialog Box
[filename, pathname] = uiputfile('*.bmp;','Save Image', filename);
sum – Add all element of matrix or vector
mean – Return mean of matrix or vector
strcat – String concatenation (+ operator for string not supported)
a(:) – Return Nx1 matrix considering a multi-dimensional.
17