Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATLAB Practice 2 Introducing MATLAB Lecture Notes on Video Search & Mining, Spring 2012 Presented by Jun Hee Yoo Biointelligence Laboratory School of.

Similar presentations


Presentation on theme: "MATLAB Practice 2 Introducing MATLAB Lecture Notes on Video Search & Mining, Spring 2012 Presented by Jun Hee Yoo Biointelligence Laboratory School of."— Presentation transcript:

1 MATLAB Practice 2 Introducing MATLAB Lecture Notes on Video Search & Mining, Spring 2012 Presented by Jun Hee Yoo Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr

2 Function MATLAB Practice 2 – MATLAB Introduce © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr2

3 Function MATLAB functions Multiple input arguments Multiple returns void input arguments void returns © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr3 function [output1, output2] = foo(input1, input2, input3) Statements end function foo Statements end

4 Function In function statement You can use ‘return’ keyword but it’s not mandatory You must declare variable or matrix that has same name as outputs before return or end of function. © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr4 function [output1, output2] = foo(input1, input2, input3) Statements return; end function [output1, output2] = foo(input1, input2, input3) …. output1 = 1; output2 = 2; …. return; end

5 Function Create function_name.m in your MATLAB © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr5 Right Click on Browser Menu Or, just CTRL+N to call empty document.

6 Function Create function_name.m in your MATLAB © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr filename must be same as function name. (in our case, this file must be saved name as foo.m)

7 Functions One function_name.m must have one primal function which name is same as file name. One function_name.m can has multiple sub- functions which located under primal functions. © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr7

8 Functions © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr8

9 Functions © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr9 Scope of variables Scope of MATLAB is like C/C++ or JAVA Generally, every internal function variables – exclude return values - in function are removed when function is returned. But, with persistent keyword, internal function variables will remain after function returned.

10 Useful Tips help function_name | command_name show the description of function or command. lookfor keywords This command takes some time. © 2012, SNU CSE Biointelligence Lab., http://bi.snu.ac.kr10


Download ppt "MATLAB Practice 2 Introducing MATLAB Lecture Notes on Video Search & Mining, Spring 2012 Presented by Jun Hee Yoo Biointelligence Laboratory School of."

Similar presentations


Ads by Google