Lecture 1: Matlab Universe

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 4.
Here is a preview of one type of problem we are going to solve using matrices. Solve this system of equations:
Please CLOSE YOUR LAPTOPS, and turn off and put away your cell phones, and get out your note-taking materials. Today’s Gateway Test will be given during.
Linear Simultaneous Equations
Matrix Mathematics in MATLAB and Excel
Gateway Quiz Reminders: The next Gateway will be given in class next week or the week after )check your course calendar.) Before then, each student who.
Copyright © Cengage Learning. All rights reserved. 7.6 The Inverse of a Square Matrix.
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
Mathcad Variable Names A string of characters (including numbers and some “special” characters (e.g. #, %, _, and a few more) Cannot start with a number.
Chapter 10 Review: Matrix Algebra
Fall 2006AE6382 Design Computing1 Vectors and Matrices Lecture Basic vector & matrix concepts Creating arrays and matrices Accessing matrix components.
Equation --- An equation is a mathematical statement that asserts the equality of twomathematicalstatement expressions. An equation involves an unknown,
Systems of Linear Equation and Matrices
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to MATLAB
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Review of Matrices Or A Fast Introduction.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
Learner’s Guide to MATLAB® Chapter 2 : Working with Arrays.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Lecture 28: Mathematical Insight and Engineering.
4.7 Identity and Inverse Matrices and Solving Systems of Equations Objectives: 1.Determine whether two matrices are inverses. 2.Find the inverse of a 2x2.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Intro to Matlab 1.Using scalar variables 2.Vectors, matrices, and arithmetic 3.Plotting 4.Solving Systems of Equations Can be found at:
CMPS 1371 Introduction to Computing for Engineers MatLab.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
A string is an array of characters Strings have many uses in MATLAB Display text output Specify formatting for plots Input arguments for some functions.
MM150 Unit 3 Seminar Agenda Seminar Topics Order of Operations Linear Equations in One Variable Formulas Applications of Linear Equations.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
MATLAB – PT1 The purpose of this workshop is to get you started and to have fun with MATLAB! Let’s talk a little and decide on what we will be covering.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Warm- Up Solve the following systems using elimination or substitution : 1. x + y = 6 -3x + y = x + 4y = 7 x + 2y = 7.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Gateway Quiz Reminders: The next Gateway will be given in class next week (check your course calendar.) Before then, each student who did not score 8/8.
Please CLOSE YOUR LAPTOPS, and turn off and put away your cell phones, and get out your note- taking materials.
Lecture 1: Matlab Universe Tom Rebold ENGR 52. Course Overview.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
Warm Up Multiply the matrices. 1. Find the determinant. 2. –1 Welcome! I’m so glad you’re here! Please get your Calculator. Please get started on this.
T4.4 – Linear Systems & Matrices
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
10.4 Matrix Algebra. 1. Matrix Notation A matrix is an array of numbers. Definition Definition: The Dimension of a matrix is m x n “m by n” where m =
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to Matlab
Introduction to MATLAB
Please CLOSE YOUR LAPTOPS,
Chapter 7 Matrix Mathematics
Lecture: MATLAB Chapter 1 Introduction
Gateway Quiz Reminders:
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
(Mohammed Sami) Ashhab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Matlab Training Session 2: Matrix Operations and Relational Operators
Presentation transcript:

Lecture 1: Matlab Universe Tom Rebold ENGR 196.3

Course Overview

The Way the Class Works I lecture for 15 – 20 minutes You do lab for 30 – 40 minutes Labs link to extra Problems online for fast students Everyone turn in a solution to the last problem they solve today HOMEWORK: Bring in 3 Math problems to solve…medium, hard, impossible We’ll have independent study time

To Buy Matlab Student Version, $100 Can purchase, download online Link from ENGR196.3 class webpage Bookstore does not stock MATLAB retails for $1600, so it’s a pretty good deal

Why MATLAB Compared to other choices: C++, Fortran, Java Excel, MathCad, Mathematica, Labview Matlab is a Very High Level Language Designed for complex numerical calculations Vast array of Toolboxes for different specialties Excellent visualization tools Symbolic math somewhat awkward Simulink for modelling dynamic systems

Today’s Agenda MATLAB Overview Working in MATLAB’s Environment Simple calculations, variables Vectors, Matrices, Plotting Applications—Problem Solving Systems of equations Analyzing a data file 3D Plotting

MATLAB’s ENVIRONMENT

Download week1.zip Follow instructions in Lab1 View toolbox demos Experiment with workspace configuration

Numeric Data At it’s most basic level, Matlab can be used as a simple calculator, by typing in an arithmetic expression and hitting enter. For example, at the command prompt, type: >> 8/10 >>4 * 3 >>8/10 + 4*3 >>9^2 (what does the ^ operator do? )

Arithmetic rules of precedence >> 8 + 3*5 >> 8 + (3*5) >> (8 + 3) * 5 >> 4^2 – 12 >> 8/4*2 >> 8/(4*2) >> 3*4^2 >> (3*4)^2 >> 27^(1/3) >> 27^1/3

built in functions Matlab has hundreds of built in functions to do more complicated math sqrt(9) log10(1000) log(10) pi cos(pi) i exp(i*pi)

Variables Usually we need to hang on to the result of a calculation We need a way to name memory for storage Variable--name of a place in memory where information is stored r = 8/10 r s=20*r score = 4 * r + s z = sqrt(1000) z = sqrt(s)

Assignment Operator = means “gets” Translation: OK in Math MATLAB: r = 8/10 ENGLISH: r “gets” the value 8/10 OK in Math x + 2 = 20 NOT OK IN MATLAB !! (only variable on Left Side)

Expressing Math in MATLAB 2 yx _______________ x-y 3x _______________ 2y

Saving Work in Matlab Script (.m) files You’ll want to build up complex calculations slowly Try, correct, try again, improve, etc .m Files store your calculations Can be edited in Matlab Can be re-executed by typing the file name

Example .m file Volume of a Cylinder. The volume of a cylinder is V= pr2h. A particular cylinder is 15 meters high with a radius of 8 meters. We want to construct another cylinder tank with a volume 20% greater, but with the same height. How large must its radius be? The session follows: r = 8; h = 15; V = pi*r^2*h V = V + 0.2*V  adds 20% to V r = sqrt(V/ (pi * h)) Put this in a file called cyl_volume.m to save retyping

Finish Section IV If you finish early, please follow the link to practice problems online

Vectors Matlab has a very concise language for dealing with vectors (arrays of data) scalar: x = 3 vector: x = [1 0 0] A vector is a series of data grouped together Row Vectors and Column Vectors Transpose operator Functions and Arithmetic with vectors Colon operator Multiplication—cell by cell vs ‘dot product’

Finish Section V If you finish early, please follow the link to practice problems online

Basic Plotting Experimental Results Mathematical Formulas v = [20:10:70]; d = [46, 75, 128, 201, 292, 385]; plot(v, d); Mathematical Formulas x=[0:0.01:2]; y=exp(-3*x).*sin(8*pi*x);  .* is needed here plot(x,y); Both involve using plot( ) on vectors

Finish Section VI Play with multiple plots, linetypes, etc If you finish early, please follow the link to practice problems online

VII Application: Polynomial Math We can represent polynomials by vectors of coefficients, for example: x3 – 9x2 + 2x + 48 represented by [1 -9 2 48] Matlab provides commands to calculate Roots Multiplication and division of polynomials Example on structural resonance online More problems online

VIII Matrices A matrix is a 2 dimensional vector Useful tools: 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1 Useful tools: Transpose Cell address Merging and extracting vectors multiplication

IX Application: Systems of Equations A common occurrence, need to solve a system of simultaneous equations: 3x + 4y + 5z = 32 21x + 5y + 2z = 20 x – 2y + 10z = 120 A solution is a value of x, y, and z that satisfies all 3 equations In general, these 3 equations could have 1 solution, many solutions, or NO solutions

Using Matlab to Solve Simultaneous Equations Set up the equation in matrix/vector form: A = [3 4 5; 21 5 2; 1 -2 10] u = [ x y z]’ b = [ 32 20 120]’ In other words, A u = b (this is linear algebra) 3 4 5 21 5 2 1 -2 10 x y z 32 20 120 * =

The solution uses matrix inverse If you multiply both sides by 1/A you get u = 1/A * b In the case of matrices, order of operation is critical (WRONG: u = b/A ) SO we have “Left division” u = A \ b (recommended approach) OR use inv( ) function: u = inv(A) * b

The solution >> u = A\b u = 1.4497 ( value of x) -6.3249 ( value of y) 10.5901 ( value of z) You can plug these values in the original equation test = A * u and see if you get b

Caution with Systems of Eqs Sometimes, Matrix A does not have an inverse: This means the 3 equations are not really independent and there is no single solution (there may be an infinite # of solns) Take determinant det(A) if 0, it’s singular 1 -1 0 1 0 -1 0 1 -1 x y z 32 10 22 * =

Application: Analyze Data from A Real Science Project

http://geodynamics.jpl.nasa.gov/antarctica/mbl.html

Data Files