%Lecture Week 1 %August 27, 2007 Section 001 %August 30, 2007 Section 002 %Adding two numbers. See how 1+1 is getting assigned to the variable aa aa=1+1 %assigning the value of each number and resulting variable aa=3 bb=7 cc=aa+bb %Find Stress if force=12 and area=4.5 Force=12 Area=4.5 Stress=Force/Area %Find sin(pi/4) and cos(pi) aa= sin(pi/4) bb=cos(pi) % How to print a file and how to print the output % To print a m file, just go File -> Print % To print the command window, just go to File -> Print % Find the area of a rectangle of length 12" and height 6.5" Length=12 Height=6.5 Area=Length*Height % Supressing an output. By using a semicolon (;), you are supressing the % output Length=12 Height=4.3 Area=Length*Height; % Compute Area of a Circle % Diamter=13" D=23.0 Area_circle=pi*D^2/4 % Plotting graphs. Draw a graph of sin(x) from -pi to pi. % See how x is being defined. It is defined as numbers going from -pi to pi % in increments of 0.1. Smaller the increments, more computer time is used, % but smoother would be the curve. x = -pi:0.1:pi; y = sin(x); plot(x,y) % How to get help % type this % help plot % in the command window % Plot 2 exp(x) from x=2.0 to 5.0. x=2.0:0.1:5.0; y=2*(exp(x)); plot(x,y) % Plot data that is given in arrays x=[1 2 3 5 9] y=[1 4 9 25 81] plot(x,y) % Look at the sample HW problem to see how I would like you to display the % output for the HW problem web http://www.eng.usf.edu/~kaw/sample_homework.htm % Go thru Tutorials web http://www.mathworks.com/academia/student_center/tutorials/launchpad.html web http://www.math.duke.edu/education/ccp/materials/diffeq/mlabtutor/contents.html % the Elusive sprintf command. What does the \n mean? What does the %d % mean. web http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/sprintf.html % DO AS MANY PROBLEMS FROM THE BOOK PAGES 1-83