ࡱ> 7 <bjbjUU l7|7|#7lP%P%P%P%$t%|7z%&&&&&&&R7T7T7T7T7T7T7$e9 ;x7-&&&&&x7/&&7///&(&&R7/&R7/0/1:6,D7&% p"P%:)6 R77076R<.<D7/9.02 Brain Lab J.J. DiCarlo MATLAB Project 0: Introduction * If you are already familiar with using MATLAB, feel free to skip ahead to the project 0 assignment at the end of this document. Otherwise, the goal of this project is to teach you the basics of using MATLAB, especially for plotting. At its core, MATLAB is essentially a set (a toolbox) of routines (called m files or mex files) that sit on your computer and a window that allows you to create new variables with names (e.g. voltage and time) and process those variables with any of those routines (e.g. plot voltage against time, find the largest voltage, etc.). It also allows you to put a list of your processing requests together in a file and save that combined list with a name so that you can run all of those commands in the same order at some later time. Furthermore, it allows you to run such lists of commands such that you pass in data and/or get data back out (i.e. the list of commands is like a function in most programming languages). Once you save a function, it becomes part of your toolbox (i.e. it now looks to you as if it were part of the basic toolbox that you started with). For those with computer programming backgrounds: Note that MATLAB runs as an interpretive language (like the old BASIC). That is, it does not need to be compiled. It simply reads through each line of the function, executes it, and then goes on to the next line. (In practice, a form of compilation occurs when you first run a function, so that it can run faster the next time you run it.) To start MATLAB: Option 1: To launch MATLAB on any Athena workstation, from the terminal type: athena% add 9.02 athena% matlab-9.02 & The first time you run MATLAB on a workstation it will take a few moments to start; please be patient. This will run MATLAB in a new window. We highly recommend that you create a directory, ~/9.02, in your Athena locker by typing: athena% cd athena% mkdir 9.02 You should then place all of the 9.02 files you create into this directory. Option 2: To launch MATLAB on one of the Macintosh G4 machines in the teaching lab: Double-click the MATLAB icon in the doc at the bottom of the page and wait for the command window to appear (this can take a minute or so, so be patient). Option 3: If you are already familiar with MATLAB, and have a copy on your personal machine, feel free to use that copy. All the toolboxes used in this course can be downloaded from the Stellar site. It is up to you to make sure your paths are set correctly and that you have a compatible version of MATLAB (the current MATLAB version is listed on the Stellar site along with the toolboxes). If you are not familiar with MATLAB, do not choose this option as you will likely spend a great deal of time just getting the program to run. The staff will not assist you in any way should you choose this option. Once you have started MATLAB: When you run MATLAB you should see a brief splash screen, followed by a command window with the following: < M A T L A B > Copyright 1984-2004 The MathWorks, Inc. Version 7.0.1.24704 (R14) Service Pack 1 September 13, 2004 To get started, type one of these: helpwin, helpdesk, demo, help help, whatsnew, info For Athena-specific information, type: help athena For product information, visit www.mathworks.com >> Note, at any time, you can always learn almost anything you want to know about MATLAB by typing >> helpwin The goal of MATLAB Project 0 is to teach you how to create some basic types of variables in MATLAB and how to plot those variables. We provide a brief tutorial here, but if you are new to MATLAB, we suggest that you explore some of the basic tutorials found in the MATLAB section of the help window. Creating variables in the MATLAB workspace Try creating your first variable. The prompt should look like: >> Type: >> x = 3 You should see: >> x = 3 x = 3 >> You have just created a variable named x and set its value equal to 3, and MATLAB has echoed that value back to you. If you now type x (no quotes), MATLAB will tell you the value of x. >> x x = 3 >> Create another variable (e.g. y = 4). Now type whos You should see: >> whos Name Size Bytes Class x 1x1 8 double array y 1x1 8 double array Grand total is 2 elements using 16 bytes >> You have just asked MATLAB about what variables it now knows about. These variables live in something called the MATLAB workspace. You do not need to worry about this, but know that you can always see the names of all your variables by typing whos. If you want to clear all your variables, you can type clear all. >> >> whos Name Size Bytes Class x 1x1 8 double array y 1x1 8 double array Grand total is 2 elements using 16 bytes >> clear all >> whos >> If you do not what MATLAB to echo the variables and values you create back at you, put a semi-colon at then end of each statement. The character % is the comment character anything after this is ignored by MATLAB. Also, once you have created a variable, you can always change its value later: >> >> x = 3; % create variable x and set its value to 3 >> x % ask for the value of variable x x = 3 % MATLAB reports variable x is equal to 3 >> x = 5; % set the value of variable x to 5 >> x % ask for the value of variable x x = 5 % MATLAB reports variable x is equal to 5 >> Try some basic algebra: >> >> x = 3; >> y = 6; >> d = y-x % subtraction d = 3 >> m = y*x % multiplication m = 18 >> r = y/x % division r = 2 >> z = x^2 % raise to a power (squaring in this case) z = 9 >> z2 = (x^2) + (y^2) z2 = 45 Creating vector and arrays The variables you created above were all scalars (only one value for each variable). MATLAB was actually built around the use of vectors and arrays, so it is very efficient at processing vectors and arrays. Vectors are lists of numbers. Create a vector called v1 with three elements (note the use of the square brackets): >> v1 = [ 4 2 9] v1 = 4 2 9 >> And another vector called v2 (also with three elements): >> v2 = [ 3 2 10] v2 = 3 2 10 >> Now do some vector math: >> >> v1 - v2 ans = 1 0 -1 >> (ans is shorthand for answer. It is a variable that currently contains your solution but will be overwritten the next time it is used. ) What if v1 and v2 contain a different number of elements? Can you subtract them? If you do not know, try it by making a four dimensional vector v3. >> v3 = [3 4 5 6] v3 = 3 4 5 6 >> To create arrays, we use semi-colons (here we make 3 x 3 arrays and subtract them): >> a1 = [1 2 3 ; 4 5 6 ; 7 8 9] a1 = 1 2 3 4 5 6 7 8 9 >> >> a2 = [1 1 1 ; 2 2 2 ; 3 3 3] a2 = 1 1 1 2 2 2 3 3 3 >> >> a1-a2 ans = 0 1 2 2 3 4 4 5 6 >> You will not need to worry about arrays right away, but they will be important later when we make images. An image is an array of pixel values. Plotting vectors Most plotting involves vectors. For example, suppose y = f(x) and I want to make a plot of that functional relationship. Mathematically, x is a continuous variable that can take on any real value. However, in the digital world, x is and y are typically sampled at some interval. For example, suppose y = x2 and I want to plot that relationship over a range of x from 0 to 10. To start, we create a vector x sampled at a fixed interval (in this case the interval is 1). >> >> x = [0:1:10] x = 0 1 2 3 4 5 6 7 8 9 10 >> >> If you do not type an interval, the default interval is 1. E.g. x = [1:10] would give you the same thing. Now we create the variable y at all the sampled x points using the known functional relationship (squaring in this case). We want to compute the squaring element-by-element, that is, we want to compute x[1]*x[1], x[2]*x[2], etc. Matlab indicates per-element operations by use of the . (i.e. the period). For example: >> >> y = x.^2 y = 0 1 4 9 16 25 36 49 64 81 100 >> Now, it is simple to plot y as a function of x over this range >> >> plot(x,y) % run the MATLAB function called plot using your data in x, y >> When you type this command, a new figure will open and you should see the following figure:  Congratulations! You have just run your first MATLAB function and made your first plot. To learn more about any MATLAB function you can always type help and the name of the function. You can also find more info about each function and available functions in the MATLAB help window (mentioned at the top of this document). >> >> help plot % help IS IMPORTANT TO REMEMBER IF STUCK ! (If the help text scrolls by too quickly, you can make it stop after each page by typing more on, and then re-running your help command.) Here are some basic plotting tricks to help you out: >> xlabel('my x label'); >> ylabel('my y label'); >> text(2,2,'my text') % will add text on the plot at values x=2, y=2 >> figure % Will open a new figure window to make a plot >> clf % Will clear the contents of the current figure window >> hold on % will allow you to keep plotting to the same figure without erasing what is already there For example, try this: >> figure(1) >> clf >> plot(x,y) >> hold on >> plot(x,y*2,'r') % make this plot red, see below >> clf One of the cool things about plotting in MATLAB is that you can control a lot of the details about how the plot looks. For example, type this: >> h = plot(x,y); >> get(h) In this case, plot will run as before and also return a handle in variable h to all the elements of the plot. get displays the current setting of all those elements. You can change the elements like this: >> set(h, 'color', 'r') % set the color of the plot line to red ('r'). Other colors are blue ('b'), black ('k'), green ('g'), etc. >> set(h, 'lineStyle', '--'); % make the plotting line a dashed line. other common options are '-' (solid line) and ':' (dotted) A shortcut to do all of this is: >> plot(x, y, 'r--'); % plot y as a function of x in a red dashed line Note that MATLAB always tries to scale the plot axes so that you can see everything in the plot. You can override this by using the command axis: >> figure(1) >> clf >> plot(x,y) >> axis([-2 12 -1 20]) % format is: [minX maxX minY maxY] I think you should have the basic idea from here. Get comfortable by playing with options, typing help xx and using the examples in the help window. Things to try: >> x = [0:(pi/10):(4*pi)]; % x runs from 0 to 4p in intervals of 0.1p >> y = sin(x) >> figure(1) >> clf >> plot(x,y) Help with debugging We fully anticipate that some parts of the following projects will be difficult. Sometimes your code won t work, and you ll spend 30 minutes staring at it without luck. This is normal. Before asking the Matlab TA, we recommend the following: First, exhaust your existing help resources. Many of these are listed on the Stellar site, including the OLC Matlab Stock Answers and The Mathworks Web Site Take a break and work on something else. When you spend a great deal of time on a piece of code, you often miss the same error over and over again. This is why its important to start these projects early. Athena consulting : e-mail  HYPERLINK "mailto:olc@mit.edu" olc@mit.edu. OLC will not help you with your code, but they will help you if you are having difficulty saving files, using a text editor, or have other questions about the Athena Experience When you ask the TA for help, please include: A copy of the code in question An exact explanation of the error. A terse my code doesnt work may be met with an equally terse so? from the TA. A specific subject header. function_foo() returns unexpected value is more likely to get a response then HELP ME MATLAB DOESNT WORK An explanation of the things you have tried. What web resources have you looked at already? What solutions have you tried? This will save your time and the time of the TA. Your time is valuable! Learn to debug intelligently and ask useful questions so we can help you be successful as quickly as possible! MATLAB Project0 assignment The goal of this assignment is to make a plot of voltage as a function of time. The final plot should show all the data and have appropriate labels on each axis. The plot should also have a solid, black horizontal line at voltage = 0 to show the zero level. It should also show the maximum and minimum voltage with text next to that voltage indicating the actual value of the maximum voltage (e.g. max = xx). (hint: try help max) For Project 0, hand in: A printout of your plot with your Athena username on it. To get started, load the variables containing data that we have saved for you in a file. >> clear all >> load('/mit/9.02/matlab/project0/data') % this loads data into the workspace % (as if you had type it in) >> whos % shows you the variables that now exist in the workspace >> The information in this document and the MATLAB help menu have all the information you need to complete this assignment. If you have any trouble, please try the suggested support resources above. When you are done, you can save your figure using the File>Print command from the figure menu containing your plot. Use postscript level 2 color. Probably best to print to a file so that you can open and re-print later if you want. If you want to put the figure in a document (e.g. MS Word, OpenOffice, etc. ), use File>Save as and select an appropriate format (e.g. TIF). "$FG3* + , = > G v }    _b+V B*phB*OJQJ^Jph5B*CJOJQJphPJ6 OJQJ^JCJOJQJ^J5CJOJQJ\^J5\5CJOJQJCJCJ55CJ OJQJ5OJQJmHsH5CJOJQJmHsH5CJ OJQJmHsH3"#$FG34* + , = >  b < _`abWT&')  )*+VWQR34l!RS12Als&5^eEGkxzRxX %!7!l"m"##{##%%7%8%%%%%&&x&ƽ˟˫5\ B*H*phmHsH5B*CJOJQJphmHsHB*mH phsH mH sH  B*phB*mH phsH mH sH B*OJQJ^Jph B*phB*OJQJ^Jph OJQJ^J:S126l'(,-abef~~FGKLSTjjkpqxyzfg  HI[\aabuvz{RS "#wwx   * = > B K L R S f y  $!%!&!7!8!Q"R"###)#*#.#/#r#s#w#z#{###%%&%*%9%:%>%?%?%%%%%%%%%&&&x&z&{&&&'''((((((<) ^` p^p`x&y&{&'''((((((( );)G)u)})))5*V*u****.+/+A+K+L+ ,!,9,,,%-'-J-`- .$.'.H._......,/00*0,0.0J0000022P2333jB*Uph6]B*mH phsH OJQJB*OJQJ^JphmH sH mH sH  5B*ph B*ph B*phjB*UphB<)=)v))***4*5*B*I*V*a*****.+/+A+K+L+ ,!,,, ^` @ ^@ `,'-)-J----&.'.4.;.H....//,/-/.0J0d0r00000 ^`  ^` 00P223445}5666:7;7<7=7X7Y777 99&9`9a9999 & F & F & F333446:7;7<7=7X7Y77`9999:B:::<ݼ 5B*ph5>*B*ph5B*CJOJQJph B*ph OJQJ^J B*ph 0JB*phjB*UphjI8B*Uph999:9::::::J;K;< @ ^@ `  ^` / =!"#$%I8Dd)4+l  B  C AxxR7KaEY \B7D~F7KaEY \BJFIFC    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222)" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( +V,u`k]BK{ȻT rc17R֥}?Y2Jj C+|10rv_7F-]-Ŭ ]Iݻ`c&?NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(ס*NC^(7ĺp^N]IX.@ IH@Q@Q@Q@Q@Q@Q@toZ@ `Ht#1C7ۧ;y]=DQ:ʢL^ <À0zJ(/JFqqw5ޡypyhX"sg9$?<RA\?xkV)h((?N>}\gۏ/Y{t( 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Body Text B*ph8Z@"8 Plain TextCJOJQJ^J.U@1. Hyperlink >*B*ph:P@B: Body Text 25B*\ph#7l"#$FG34*+,=> b_ ` a b  W   T &')*+VWQR34l!RS126l'(,-abef~FGKLSTjkpqxyzfg  HI[\abuvz{RS "#wx*=>BKLRSfy$%&78QR)*./rswz{%!&!*!9!:!>!?!!!!!!!!!"""x"z"{"""###$$$$$$<%=%v%%&&&4&5&B&I&V&a&&&&&.'/'A'K'L' (!(((')))J))))&*'*4*;*H****++,+-+s+++++++++,I-./C/b//b0111111112W2i3j333344$4Q4R4x44444455%700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 0 0 0 0 0 0 0000000000000 0000000000000000x&3<"(04 )S~jaw ?%<),09<#%&')*+,-./1235<$3.U.a.#7X"G P     GKQSWj{ */=EKLR !!$$$$$$y%|%8&B&E&I&L&V&i&l&&&2'A'((**4*7*;*>*H*m*q*r*v*w*{*|****v++++++++,,--6-?-/04466%7!$3    M S &267no EQUV9:op()GJQSTikmLN\^x )/<>ABJLQqs),*+ !!!-!.!:!;!!!""##$$$$$$@%F%y%|%%%5&A&B&H&I&U&Y&]&d&h&&&/'@'D'G'''$('(((((M)Q)'*3*4*:*;*G*K*O***0+1+s++++++++.+.//S3W344'4+4T4X4{4}44456:666%7333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 / T '+!&!*!9!:!D!++.d.44%7 Eric JonasAY:\9.02\projects\project.00\handouts\MATLAB project0 tutorial.doc Eric Jonas&Y:\9.02\projects\project0\tutorial.doc Eric Jonas&Y:\9.02\projects\project0\tutorial.doc Eric Jonas&Y:\9.02\projects\project0\tutorial.doc Eric Jonas&Y:\9.02\projects\project0\tutorial.docL9:{JBAn@h ^`OJQJo(h ^`OJQJo(oh pp^p`OJQJo(h @ @ ^@ `OJQJo(h ^`OJQJo(oh ^`OJQJo(h ^`OJQJo(h ^`OJQJo(oh PP^P`OJQJo(h ^`OJQJo(h ^`OJQJo(oh pp^p`OJQJo(h @ @ ^@ `OJQJo(h ^`OJQJo(oh ^`OJQJo(h ^`OJQJo(h ^`OJQJo(oh PP^P`OJQJo(L9:JB                   @@"7"7L"7"7(\+\,#7@@@0@d@UnknownG: Times New Roman5VSymbol3& : Arial?5 : Courier NewG MS Mincho-3 fg;VWingdings qh;ۑ&v-`$20d7 3QBrain lab: Matlab tutorial James DiCarlo Eric Jonas Oh+'0) $ @ L Xdlt|Brain lab: Matlab tutorial MiraiJames DiCarlotlame Normal.dotl Eric Jonasl38cMicrosoft Word 9.0t@h"@`@v-G'VT$mz  &WordMicrosoft Word   "{w{@ ~wwwtw\2-@"Arial{~ ~wwwtwy2-  2 *w 9.02 Brain Lab%%%0%))%)@"Arial{~ ~wwwtwy2- 2 3A 2 3 2 3e 2 3 2 3 2 3' 2 3 @"Arial{~ ~wwwtwy2-2 9S  J.J. DiCarlo$$ 2 9g - 2 ww % 2 w %=2 w! MATLAB Project 0: Introduction 9-()-0-)%%%))))%)) 2  %@Times New Romanwwtwy2- 2 _w @Times New Romanwwtwy2-2 wP * If you are already familiar with using MATLAB, feel free to skip ahead to the       )  $  0$!!$"        2 wW project 0 assignment at the end of this document. Otherwise, the goal of this project   )      ) '$      &2 w is to teach you th    V2 2 e basics of using MATLAB, especially for plotting.    0$!!$"      2  - 2 Ew 2 ~wX At its core, MATLAB is essentially a set (a toolbox) of routines (called m files or #   ,##!               %    2 wS mex files) that sit on your computer and a window that allows you to create new %        %   $ $   $    $ =2 w! variables with names (e.g. voltag   $  %    Y2 4 e and time) and process those variables with any of    %       $    2 +wP those routines (e.g. plot voltage against time, find the largest voltage, etc.).            %         2 +J  2 dw 2 w^ It also allows you to put a list of your processing requests together in a file and save that     $                   52 w combined list with a name so%   $   % g2 = that you can run all of those commands in the same order at        %%   %   2 wY some later time. Furthermore, it allows you to run such lists of commands such that you %   % %   $       %%    2 Jw\ pass in data and/or get data back out (i.e. the list of commands is like a function in most              %%       %  2 w programming la%%  |2 K nguages). Once you save a function, it becomes part of your toolbox (i.e.  $       %        2 wU it now looks to you as if it were part of the basic toolbox that you started with).  $       $           $  2   2 w @Times New Romanwwtwy2-2 /w^ For those with computer programming backgrounds: Note that MATLAB runs as an interpretive lang    !  !!      %       2 /. uage  2 _wk (like the old BASIC). That is, it does not need to be compiled. It simply reads through each line of the              !    !        2 wo function, executes it, and then goes on to the next line. (In practice, a form of compilation occurs when you                 !  !      =2 w! first run a function, so that it        I2 i) can run faster the next time you run it.)      !    2  - 2 w @Times New Romanwwtwy2- 2 )w -#2 lw To start MATLAB:##  1)##)* 2 la - 2 w -2 w  Option 1:' -s2 EE To launch MATLAB on any Athena workstation, from the terminal type:   ,##!   # $  %  %   2    2 "w @1Courier New ~wwwtwy2-2 Zw athena%@1Courier New ~wwwtwy2- 2 ]&  add 9.02 2 ] -2 w athena%- 2 & matlab 2  -2  9.02 & - 2   2 w %y2 wI The first time you run MATLAB on a workstation it will take a few moments    %   ,##!   $   $   $ %%2 y  to start;   2 - wS please be patient. This will run MATLAB in a new window. We highly recommend that        $  ,##!   $ $ $ .    %%  -/2 i w you create a directory,      @1Courier New ~wwwtwy2- 2 o C ~/9.02,-=2 i ! in your Athena locker by typing:   #     2 i   2 w -2 w athena% - 2 ? cd- 2 q  2  -2 w athena% - 2  ?  mkdir 9.02- 2 9 - 2 < w k2 v w@ You should then place all of the 9.02 files you create into this$                 2 v :  directory.   2 v   2 w -2 w  Option 2:' -t2 EF To launch MATLAB on one of the Macintosh G4 machines in the teaching   ,##!     ,  $ %      2 " w lab:  2 "  -                            ՜.+,D՜.+,|8 hp|  MIT`7 Brain lab: Matlab tutorial  Help with debugging Title Headings 8@ _PID_HLINKSA Egmailto:olc@mit.eduxxx&xx  !"#$%&'()*+,-./012345689:;<=>?@ABCDEFGHIJKLMNOPQRSUVWXYZ[\]^_`abcdefghijklmnopqrtuvwxyz{|}~Root Entry F ¨Data 781TableT<WordDocumentlSummaryInformation(s)DocumentSummaryInformation8CompObjjObjectPool ¨ ¨  FMicrosoft Word Document MSWordDocWord.Document.89q