Dr. Jie Zou PHY 33201 Welcome to PHY 3320 Computational Methods in Physics and Engineering.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

Lecture 5.
259 Lecture 17 Working with Data in MATLAB. Overview  In this lecture, we’ll look at some commands that are useful for working with data!  fzero  sum,
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Insight Through Computing 10. Plotting Continuous Functions Linspace Array Operations.
Introduction to Matlab
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
1 Chapter 4 Curve Plotting with MATLAB MATLAB provides some very powerful features for plotting and labeling curves. These operations can be performed.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Dr. Jie Zou PHY Chapter 9 Ordinary Differential Equations: Initial-Value Problems Lecture (I) 1 1 Besides the main textbook, also see Ref.: “Applied.
Solution of Simultaneous Linear Algebraic Equations: Lecture (I)
Introduction to MATLAB
Dr. Jie Zou PHY Introduction to MATLAB Programming with MATLAB 1 1 Applied Numerical Methods with MATLAB for Engineers and Scientists, 2nd ed., Steven.
Exam #3 Review: Comprehensive Exam Class 14.2 Palm Matlab Book Ch. 1-5.
Numerical Integration Lecture (I)1
Matrix Mathematics in MATLAB and Excel
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB Fundamentals.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to MATLAB
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
1 Yangon Technological University Department of Mechanical Engineering Computer Application In Mechanical Engineering I ME Dr. Yin Yin Tun Deputy.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Working with Arrays in MATLAB
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Introduction to MATLAB II Steve Gu Jan 25, Outline Matrix Operation –Matrix functions –Element-wise operations Dynamic Systems –Classification –2nd.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Array Accessing and Strings ENGR 1187 MATLAB 3. Today's Topics  Array Addressing (indexing)  Vector Addressing (indexing)  Matrix Addressing (indexing)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
ECE 1304 Introduction to Electrical and Computer Engineering
Chapter 7 Matrix Mathematics
MATLAB DENC 2533 ECADD LAB 9.
EEE 244 Numerical Methods In Electrical Engineering
Part 1 Chapter 2 MATLAB Fundamentals
MATH 493 Introduction to MATLAB
Vectors and Matrices I.
Communication and Coding Theory Lab(CS491)
Part 1 Chapter 2 MATLAB Fundamentals
Presentation transcript:

Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering

Dr. Jie Zou PHY Introduction to MATLAB: Fundamentals 1 Outline The MATLAB environment Assignment Mathematical operations Use of built-in functions Graphics 1 Applied Numerical Methods with MATLAB for Engineers and Scientists, 2 nd ed., Steven C. Chapra, McGraw Hill, 2008, Ch. 2.

Dr. Jie Zou PHY The MATLAB environment Start MATLAB, command window, command prompt >> You can type in commands line by line after >>; for each command, you get a result. Example: Type in the following and hit return >>  MATLAB will display ans = 39 MATLAB assigns the result to ans whenever you do not explicitly assign the calculation to a variable of your own choosing. Now, type in >> ans + 11  What do you think MATLAB will display?

Dr. Jie Zou PHY Assignment Assign values to variable names: scalars, arrays, vectors, and matrices. Scalars: A scalar is a single value. EnterThen enter >> a = 4  >> a = 4, A = 6;  a = 4 4 Notice Echo Printing if “,” is used; echo printing is suppressed when “;” is used. EnterThen enter >> a  >> A  Note that names are Case-Sensitive in MATLAB.

Dr. Jie Zou PHY Assignment (cont.) Arrays: An array is a collection of values that are represented by a single variable name; Vectors: 1D arrays; Matrices: 2D arrays. Examples: Create a row vector and a column vector EnterThen enter >> a = [ ]  >> b = [ 2; 4; 6]  a = or>> b = [2 4 6]’  1 2 3b = Also note that this current assignment of a Overrides the previous assignment of a = 4.

Dr. Jie Zou PHY Assignment (cont.) Example: Create a matrix >> A = [1 2 3; 4 5 6; 7 8 9]  A = Example: Access an individual element of an array >> b (2)  >> A (2, 3)  ans = 46 MATLAB built-in functions: ones (m, n), zeros (m, n), and size () >> E = zeros(2, 3)  >> u = ones (1, 3)  >> size (A) 

Dr. Jie Zou PHY Assignment (cont.) The colon “:” operator Examples >> t = 1: 5  >> t = 1: 0.5: 3  t = >> t = 10: -1: 5>> A (2, :)  t =ans = Note that when a colon “:” is used in place of a specific subscript, the colon represents the entire row or column. Now try >> t (2: 4)  What do you think the result will be? The linspace function: linspace(x1, x2, n). Try >> linspace (0,1,6) and >> linspace(0,1)

Dr. Jie Zou PHY Mathematical operations and built-in functions Common operators: ^, -, * /, + - Examples: >> 2 * pi  >> y = - 4^2  ans =y = Example: Vector-matrix calculations >> A.^2  What is the result? Built-in functions: log, exp, abs, sin, cos, sqrt, sum, min, max, mean, sort, length, etc. The Built-in functions operate directly on vector and matrix quantities. Example: >> log (A)  What is the result? For a list of all built-in elementary functions, type >> help elfun For how to use a specific built-in function, for example, sum, type >> help sum

Dr. Jie Zou PHY Graphics 2D plots: plot (x, y); 3D plots: plot3 (x, y, z); Note: x, y, and z are vectors of the same length. Example: The velocity of a falling bungee jumper:. Plot v from t = 0-20 s. Step 1: >> g = 9.81; m = 68.1; cd= 0.25; Step 2: >> t = [0:2:20]’; >> v = sqrt (g*m/cd)*tanh(sqrt(g*cd/m)*t); Step 3: >> plot (t, v) % try plot (t, v, t, v, ‘o’) Step 4: >> title (‘Plot of v versus t’) >> xlabel (‘Values of t’) >> ylabel (‘Values of v’) >> grid Also, check hold on; hold off; and specifiers for colors, symbols, and line types (see Table 2.2 on the hand out).  McGraw-Hill Companies

Dr. Jie Zou PHY Plot of v versus t After Step 3: plot After Step 4: title, xlabel, ylabel, and grid