## Xem mẫu

1. Lecture 1: Introduction Lecture Lecture series based on the text: Essential MATLAB for Engineers and Scientists for By By Hahn & Valentine Hahn http://www.mediafire.com/?y5dz4zjxrj0z4 Email: bttu@fetel.hcmus.edu.vn © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
2. MATLAB desktop MATLAB Command Window Command History Command Window Window Workspace Window Current Directory Current Window Window Start Button
3. Command Window Command The Command Window on the right is the main The Command  panel where you interact with MATLAB. You key (or type) and commands after You  the prompt >>; MATLAB executes the commands >> MATLAB and displays results (if requested). and Some commonly used tools and commands:    (up arrow) returns last command input, can be returns repeated repeated – clc – clears the screen – whos – shows list of variables – clear – clears variables
4. Evaluation of MATLAB Evaluation  HANDS­ON with MATLAB – Type >> 2+3 2+3 into the Command Window >> clc >> whos whos Throughout the lecture, yellow text indicates  what you should type into MATLAB.
5. Command History Window Command The Command History Window logs all of the The Command  commands you enter in MATLAB. commands It should have logged 2+3. It 2+3  Use the Command History Window to reenter 2+3 Use 2+3 in the command window (use copy-and- paste or double click on 2+3). double  This is useful to retrieve past commands.  Use “Shift” key to select multiple lines. Use “Shift”
6. Arithmetic with MATLAB Arithmetic with MATLAB  Let us explore by doing exercises: >> 3–2 >> 3–2 >> 3*2 >> 3*2 >> 3/2 >> 3/2 >> 3\2 >> 3\2 >> 3^2 >> 3^2 >> 2/0 >> 2/0 >> 0/2 >> 0/2 >> 3*Inf >> 3*Inf
7. Algebraic­numeric computations Algebraic­numeric computations  Let us explore by doing exercises: >> a= 3 >> >> b= 2 >> >> a– b >> >> a/ b >> >> a^2 >> a^2 >> c= a*b >> >> d= c^(b+1) >> c^(b+1) >> who
8. Hiding Output Hiding Output Let us explore by doing exercises:       >> clear; clc >> clear; >> whos >> whos >> a = 3; 3; >> b = 2; >> 2; >> c = a * b; >> b; >> d = c^(b+1); c^(b+1); >> who >> >> % a, b, c, d are in workspace a, >> a, b, c, d
9. Plot y versus x Plot  Introduction to plotting & displaying data:  >> clear; clc >> clear; >> x = 0:0.1:1; >> 0:0.1:1; >> y = x.^2; >> x.^2; >> whos >> whos >> plot(x,y,x,y,’o’) >> plot(x,y,x,y,’o’) >> disp(' '),disp('...... x ........ y .....'),disp([x‘ y']) >> >> x >> >> y >> % x and y are 1-by-11 arrays of numbers! >> and
10. Write a Simple Program  Write Consider computing the volume of a cone:  Volume = (pi.*r.^2.*h)./3 radius = 6 inches height = 12 inches In the command window key in:  >> clear; clc >> clear; >> r = 6 >> h = 12 >> v = (pi.*r.^2.*h)./3 >> whos
11. Editor & M-Files Editor  An M-file in MATLAB is analogous to a txt- An M-file file in Microsoft Notepad. file  An M-file is created in MATLAB text editor. An text  M-files: – You can save your programs (i.e., list of You executable commands) as M-files. executable – You can reopen and modify your program. – They are useful for “debugging” (correcting They errors) as you develop your programs (your technical computing tools). technical