20
INTRO TO MATLAB + GUI By Syed Owais Ali Chishti (P146011)

Intro to Matlab + GUI

Embed Size (px)

Citation preview

Page 1: Intro to Matlab + GUI

INTRO TO MATLAB + GUI

By Syed Owais Ali Chishti (P146011)

Page 2: Intro to Matlab + GUI

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

Page 3: Intro to Matlab + GUI

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

Page 4: Intro to Matlab + GUI

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

Page 5: Intro to Matlab + GUI

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’

Page 6: Intro to Matlab + GUI

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

Page 7: Intro to Matlab + GUI

7

MATRIX INDEX

Page 8: Intro to Matlab + GUI

8

MATRIX OPERATIONS

+ addition- subtraction* multiplication/ division^ power‘ complex conjugate transpose

Page 9: Intro to Matlab + GUI

9

FLOW CONTROL

if ((a>3) & (b==5))Some matlab Commands;

elseif (a < 2)Some matlab commands;

elseSome matlab commands;

end

Page 10: Intro to Matlab + GUI

10

LOOPS

for i=1:100Matlab Commands;

end

while (condition)Matlab Commands;

end

Page 11: Intro to Matlab + GUI

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)

Page 12: Intro to Matlab + GUI

12

GUI APPLICATION

Starting new AppHome > New > App > GUIDEHome > New > App > App Designer

GUIDEProcedural

App DesignerObject Oriented

Both have same components

Page 13: Intro to Matlab + GUI

13

GUIDE QUICK START

Page 14: Intro to Matlab + GUI

14

ADD COMPONENTS

Page 15: Intro to Matlab + GUI

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

Page 16: Intro to Matlab + GUI

16

COMPONENT INSPECTOR• Set String Property of Button• set(handles.pushbutton1,‘String',

‘test');

• Get String Property of Button• get(handles.pushbutton1,‘String'

);

Page 17: Intro to Matlab + GUI

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.

Page 18: Intro to Matlab + GUI

18

SHOWING IMAGE

Add Axes component in GUICall imshow([…])

Page 19: Intro to Matlab + GUI

THANK YOU!