Upload
syed-owais-ali-chishti
View
139
Download
0
Embed Size (px)
Citation preview
INTRO TO MATLAB + GUI
By Syed Owais Ali Chishti (P146011)
2
INTRODUCTION
MATLAB stands for Matrix Laboratory.MATLAB had many functions and toolboxes Integration Image Processing Linear Algebra …
Is high level languageSolves computing problems in a fraction of the time
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
4
VARIABLE
No need for types int a = 10;float pie = 3.1415;
All variable are of double precision unless specifiedpie = 3.1415s = 123
All variable are 1x1 matrices
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’
6
VECTOR/MATRIX GENERATION
t = [1:10] t = 1 2 3 4 5 6 7 8 9 10
x = [1:4; 5:8]x =1 2 3 45 6 7 8
7
MATRIX INDEX
8
MATRIX OPERATIONS
+ addition- subtraction* multiplication/ division^ power‘ complex conjugate transpose
9
FLOW CONTROL
if ((a>3) & (b==5))Some matlab Commands;
elseif (a < 2)Some matlab commands;
elseSome matlab commands;
end
10
LOOPS
for i=1:100Matlab Commands;
end
while (condition)Matlab Commands;
end
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)
12
GUI APPLICATION
Starting new AppHome > New > App > GUIDEHome > New > App > App Designer
GUIDEProcedural
App DesignerObject Oriented
Both have same components
13
GUIDE QUICK START
14
ADD COMPONENTS
15
CALLBACK
Catchable event of ButtonCallback (OnClick)Create – When button is createdDelete – button is deleteButtonDown KeyPress
Execute when event/callback occur Jumps to that code
16
COMPONENT INSPECTOR• Set String Property of Button• set(handles.pushbutton1,‘String',
‘test');
• Get String Property of Button• get(handles.pushbutton1,‘String'
);
17
SOME USEFUL TIPS
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.
18
SHOWING IMAGE
Add Axes component in GUICall imshow([…])
THANK YOU!
20
REFERENCES www.eee.metu.edu.tr/~yozbek/PDF430/Introduction%20to%20Matlab.ppt