Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATLAB FOR PATTERN RECOGNITION By: Özge Öztimur. How Much Do We Know? Anybody who has never used MATLAB?

Similar presentations


Presentation on theme: "MATLAB FOR PATTERN RECOGNITION By: Özge Öztimur. How Much Do We Know? Anybody who has never used MATLAB?"— Presentation transcript:

1 MATLAB FOR PATTERN RECOGNITION By: Özge Öztimur

2 How Much Do We Know? Anybody who has never used MATLAB?

3 MATLAB Environment Workspace: Variables defined so far. Command History Command Window Edit Window Plot Window … Current Directory: Start by setting the current directory to the directoy that you are working. Generally, it is where your files are.

4 LOOKFOR & HELP LOOKFOR: Type ‘lookfor smth’ to learn the name of functions that are related to ‘smth’. HELP: Type ‘help function_name’ to learn how that function works, its inputs and outputs.

5 Everything is a Matrix Each variable in MATLAB is a matrix. For example: >> a=1; >>size(a) ans= 1 1

6 Creating Matrices >> a = [ 1 2 2 1 ] a = 1 2 2 1 >> b= [1; 2; 2; 1] b= 1 2 1

7 Accessing a Matrix >> a=[1 2; 3 4] a= 1 2 3 4 >> a(2,1) ans= 3

8 Matrix Operations Matrix operations like, Matrix addition, subtraction, multiplication Determinant of a matrix Inverse of a matrix Transpose of a matrix Element by element multiplication, division … are defined in MATLAB.

9 Flow Control-IF >> if a+b==5 m=1; elseif a+b==3 m=2; end >>

10 Flow Control-Switch >> switch (rem(n,4)==0) + (rem(n,2)==0) case 0 M=0 case 1 M=1 otherwise M=2 end

11 Loops >> a = [ 0.8 0.1; 0.2 0.9 ] >> x = [ 1; 0 ] >> for i = 1:20 x = a*x end Avoid using Loops in Matlab.

12 M-Files: Scripts And Functions Scripts: Do not accept input arguments or return output arguments.They operate on data in the workspace. M-Files: can accept input arguments and return output arguments.Internal variables are local to the function.

13 Read & Write Files Load, Save,Saveas Textread … There are many other functions for file operations. Check File I/O part in Mathwork’s Help.

14 Function Definition Name of the function and the file should be the same. function[output1,output2]=example(input)

15 Example – Generating Random Numbers Generate random numbers of size 5x3 (5 rows, 3 columns); >> a=randn(5,3);

16 Example-Distributions Parameter Estimation Examples: Normal Distribution >>[mu,sigma]=normfit(data); Binomial Distribution >> phat=binofit(data,n) …

17 Example-Probability Density Function Pdf gives the probability density function for a specified distribution >> Y=pdf(name,X,A) Where name is the name of the distribution, X is the data and A is the parameters for the given distribution.

18 Example-Maximum Likelihood Estimation mle gives the maximum likelihood estimation >> mle(data); >> mle(data,’distribution’,dist) Where dist is the name of the distribution

19 Graphical Representation Generally ‘plot’ is used for drawing graphics. >>plot(x) ; plots the columns of x versus their index. Many options are provided for this function.

20 Refer To http://www.mathworks.com/access/hel pdesk/help/helpdesk.html Course Web Page: www.ceng.metu.edu.tr/courses/secon dprog/ceng564/


Download ppt "MATLAB FOR PATTERN RECOGNITION By: Özge Öztimur. How Much Do We Know? Anybody who has never used MATLAB?"

Similar presentations


Ads by Google