CS99 Fall 2002 Lab #3 (9/17/02) Objectives + write a script M-File + $...$ notation for instructions - Enter everything between the dollar signs ($) but do NOT enter the dollar signs! + practice using MATLAB tokens - whitespace - comments - numbers - operators (arithmetic, modulus) - vectors - strings - punctuation + practice using MATLAB statements - expressions - operator precedence and associativity - assignments - I/O - plotting (0) Read the objectives, and then, write a script called $lab3.m$ in which you will do the tasks, as described below. Be sure to comment each task to clarify the problem that you are solving. (1) Comment the top using the usual format--the same one as in homework #1 and lab2. See syllabus. (2) Clear all variables and clear the screen. (3) Turning echoing of commands "on" with $echo on$. Write a comment in your code. With echoing on, MATLAB will actually echo your comment when you run your script. Turn echoing "off" with $echo off$. (4) Add 3 and 2. (5) Multiply 4 and 7. (6) Evaluate 1+3*4 such that you produce the answer 13. Do not use parentheses. (7) Redo (6), but use this expression: (1+3)*4. Write some comments about why the results from (6) and (7) are different. (8) Evaluate 3-2-1 and 3-(2-1). Write comments why these two expressions are different. (9) Find the remainder of 11/4. Hint: see $help mod$. (10) Create a vector of numbers from 1 to 15. Hint: see $help colon$. (11) Store your favorite color as string in a variable called $color$. (12) Output the value of $color$. Use the following format: My favorite color is: . (13) Plot the function x^2. Hint: see $help ezplot$. (14) Plot y=-3*x, where x goes from 1 to 10.