2008/08/271Matlab TutorialBased on Matlab tutorial by IPLab@SUTMotivation: powerful and easy! Matlab: a high-performance software and a programming language Powerful Mathematics and visualization Toolboxes in statistics, signal processing, vision… Widely used in AI-related fields Easy Prototyping, testing, debugging, finding helps…Motivation: the 80/20 rule “Remember the 80/20 rule. Hence 80% of your code should be in some high level language like Matlab… Your time is more valuable than the computer's time.”- Prof. Kevin P. MurphyOutline Environment Matrices Elementary math Data types String Cell arrays Multidimensional arrays Programming part next week! Plot, flow control, functions, debug, …2008/08/2722008/08/2732008/08/274Text strings Create a string str = ‘hello world’ disp: display any variable x = [1 2; 3 4]; disp(x); str = ‘hello world’; disp(str); fprintf: print to stdout or files fprintf(‘str=%s, one-third=%4.2f’, 1/3); Type “help fprintf” for file output sprintf: string output as CStrings are character matrices Strings are matrices in which elements are ASCII numbers x = ‘hello’; x(2)e x = ['ab‘ 'cd']abcd x = ['ab' ; 'cd']ab cd “char” creates a padded character arrays s = char('rolling','stone','momentum.') [rolling ][stone ][momentum] String arrays of different length: cell array (later)2008/08/275More to come next week! Any
View Full Document