CE890 / ENE801 Lecture 1 Introduction to MATLAB

Similar documents
Essential MATLAB for Engineers and Scientists

Contents. Implementing the QR factorization The algebraic eigenvalue problem. Applied Linear Algebra in Geoscience Using MATLAB

Table of Contents. Introduction.*.. 7. Part /: Getting Started With MATLAB 5. Chapter 1: Introducing MATLAB and Its Many Uses 7

CVEN 302. Computer Applications in Engineering and Construction. Dr. Tony Cahill Environmental and Water Resources Division

HiQ Analysis, Visualization, and Report Generation

MATLAB. Miran H. S. Mohammed. Lecture 1

PROGRAMMING AND ENGINEERING COMPUTING WITH MATLAB Huei-Huang Lee SDC. Better Textbooks. Lower Prices.

An Introduction to MATLAB See Chapter 1 of Gilat

An Introduction to MATLAB. Lab tutor : Dennis Yang LIU Lab 1: Sept. 11, 2014

Introduction to Matlab

MATLAB 7. The Language of Technical Computing KEY FEATURES

Matlab Practice Sessions

Chapter 1 Introduction to MATLAB

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

MATLAB Project: Getting Started with MATLAB

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

MATLAB Project: Getting Started with MATLAB

(Creating Arrays & Matrices) Applied Linear Algebra in Geoscience Using MATLAB

Dr Richard Greenaway

Lab 1 Intro to MATLAB and FreeMat

Chapter 1 Introduction to MATLAB

Introduction to Matlab

Teaching Engineering Analysis Using VBA for Excel. Abstract. Introduction

Eng Marine Production Management. Introduction to Matlab

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Lecture 1: Hello, MATLAB!

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Huei-Huang Lee. Programming with MATLAB2016 SDC ACCESS CODE. Better Textbooks. Lower Prices. UNIQUE CODE INSIDE

2.0 MATLAB Fundamentals

Introduction to MATLAB

Mathematica for Scientists and Engineers

GRAPHICS AND VISUALISATION WITH MATLAB Part 2

STEPHEN WOLFRAM MATHEMATICADO. Fourth Edition WOLFRAM MEDIA CAMBRIDGE UNIVERSITY PRESS

Scientific Computing: Lecture 1

ME 1020 Engineering Programming with MATLAB. Chapter 1 In-Class Assignment: 1.1, 1.3, 1.13, Topics Covered:

MATLAB for beginners. KiJung Yoon, 1. 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Introduction to MATLAB

POLYMATH Example for the Numerical Solution of ODEs

AE Computer Programming for Aerospace Engineers

Thursday 1/8 1 * syllabus, Introduction * preview reading assgt., chapter 1 (modeling) * HW review chapters 1, 2, & 3

Chapter 1: An Overview of MATLAB

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming

CPIB SUMMER SCHOOL 2011: INTRODUCTION TO BIOLOGICAL MODELLING

HERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING. B35SD2 Matlab tutorial 1 MATLAB BASICS

MS6021 Scientific Computing. MatLab and Python for Mathematical Modelling. Aimed at the absolute beginner.

MATLAB The first steps. Edited by Péter Vass

Introduction to Matlab

MATLAB Part 1. Introduction

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Polymath 6. Overview

Introduction to Matlab

개발과정에서의 MATLAB 과 C 의연동 ( 영상처리분야 )

Assignment 2 in Simulation of Telesystems Laboratory exercise: Introduction to Simulink and Communications Blockset

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System

Programming in Mathematics. Mili I. Shah

Introduction to Matlab

Session 3 Introduction to SIMULINK

Getting Started with DADiSP

Using MATLAB, SIMULINK and Control System Toolbox

Dr Richard Greenaway

A Short Introduction to Maple

ECE 202 LAB 3 ADVANCED MATLAB

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

2 T. x + 2 T. , T( x, y = 0) = T 1

Introduction to Matlab

MatLab Just a beginning

EE 216 Experiment 1. MATLAB Structure and Use

Introduction to MatLab. Introduction to MatLab K. Craig 1

Medical Image Processing using MATLAB

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li

Graphing on Excel. Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version):

Lab - Introduction to Finite Element Methods and MATLAB s PDEtoolbox

Digests from his work is presented in this chapter partly rewritten/restructured

Can be put into the matrix form of Ax=b in this way:

INTERNATIONAL EDITION. MATLAB for Engineers. Third Edition. Holly Moore

Data-Driven Modeling. Scientific Computation J. NATHAN KUTZ OXPORD. Methods for Complex Systems & Big Data

Introduction to MATLAB

Introduction to Matlab

Computer Project: Getting Started with MATLAB

Welcome to Microsoft Excel 2013 p. 1 Customizing the QAT p. 5 Customizing the Ribbon Control p. 6 The Worksheet p. 6 Excel 2013 Specifications and

Introduction to Matlab

1 Introduction to Matlab

Essential MATLAB for Engineers and Scientists

Lecture 1: What is MATLAB?

SECOND SEMESTER BCA : Syllabus Copy

Microsoft Word for Report-Writing (2016 Version)

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

ENGINEERING PROGRAMMING

Introduction to Scientific Computing with Matlab

Assignment 2. with (a) (10 pts) naive Gauss elimination, (b) (10 pts) Gauss with partial pivoting

Matlab Tutorial 1: Working with variables, arrays, and plotting

EXERCISES Introduction to MATLAB: Graphics

LAB 2: Linear Equations and Matrix Algebra. Preliminaries

EE168 Lab/Homework #1 Introduction to Digital Image Processing Handout #3

Lecture 14. Resource Allocation involving Continuous Variables (Linear Programming) 1.040/1.401/ESD.018 Project Management.

Introduction to MATLAB

Practice to Informatics for Energy and Environment

Transcription:

CE890 / ENE801 Lecture 1 Introduction to MATLAB

CE890: Course Objectives Become familiar with a powerful tool for computations and visualization (MATLAB) Promote problem-solving skills using computers Learn programming skills Learn to do numerical analysis using MATLAB

Textbook Essential MATLAB for Engineers & Scientists By Brian Hahn & Daniel Valentine 3 rd Edition (2007) Elsevier

Grading Homework assignments (4): 60% of final grade Final Project: 40% of final grade There will be one homework assignment every week DECS computer labs are reserved for hands-on sessions

Syllabus Introduction to MATLAB: Variables, constants, m-files (scripts and functions), operators, control flow, strings, cell arrays, y, built-in functions, help and matlab documentation MATLAB Graphics: XY plots (line, scatter, bar, probability and polar plots), two-dimensional graphs including contour plots, filled contour plots, quiver or vector plots, stream function plots; working with images; three-dimensional plots:iso- surfaces, adjusting light, shading and camera positions, creating movies / animations, reading data into MATLAB, exporting plots and animations in various formats Numerical Analysis: Root finding, Newton - Raphson method; Interpolation (one- and multidimensional interpolation; splines); Numerical integration: Simpson's s rule, Gaussian quadrature; Numerical Linear Algebra: Vectors and matrices in MATLAB; determinants and inverse of a matrix; Solving systems of linear equations; eienvalues, LU decomposition; singular value decomposition; sparse matrices; connection between graphics and linear algebra; Solution of ordinary differential equations: Runge - Kutta method; Two-point boundary value problems; Systems of Differential Equations; Algorithms for Stiff Differential Equations Toolboxes and Advanced Programming Techniques in MATLAB: Vector versus scalar computation; Memory management; MEX-files and Dynamic Link Libraries (DLLs); The MATLAB compiler; Toolboxes; How to create your own toolbox?

Strengths of MATLAB MATLAB is relatively easy to learn MATLAB code is optimized to be relatively quick when performing matrix operations MATLAB may behave like a calculator or as a programming language MATLAB is interpreted, errors are easier to fix

MATLAB: Matrix Lab Images, movies, sound and variables all are matrices in MATLAB Sound: load chirp sound(y) Image: load clown image(x), colormap(map) Animations (movies): z = peaks; surf(z); axis tight set(gca,'nextplot','replacechildren'); for j = 1:20 end movie(f,50) surf(sin(2*pi*j/20)*z,z) f(j) = getframe;

MATLAB is both a Software tool and a computer language

Matlab Desktop Launch Pad Command Window History

Matlab Help

Command Window The Command Window on the right is the main panel where you interact t with MATLAB. You key (or type) and <Enter> commands after the prompt >>; MATLAB executes the commands and displays results (if requested). Some commonly used tools and commands: (up arrow) returns last command input, can be repeated clc clears the screen whos shows list of variables clear clears variables

Evaluation of MATLAB HANDS ON with MATLAB Type >> 2+3 <Enter> into the Command Window >> clc <Enter> >> whos <Enter> Throughout h the lecture, red text indicates what you should type into MATLAB.

Command History Window The Command History Window logs all of the commands you enter in MATLAB. It should have logged 2+3. Use the Command History Window to reenter 2+3 in the command window (use copy-and- ) paste or double click on 2+3). This is useful to retrieve past commands. Use Shift key to select multiple lines.

Arithmetic with MATLAB Let us explore by doing exercises: >> 3 2 <Enter> >> 3*2 <Enter> >> 3/2 <Enter> >> 3\2 <Enter> >> 3^2 <Enter> >> 2/0 <Enter> >> 0/2 <Enter> >> 3*Inf <Enter>

Algebraic numeric computations Let us explore by doing exercises: >> a = 3 <Enter> >> b = 2 <Enter> >> a b <Enter> >> a / b <Enter> >> a^2 <Enter> >> c = a * b <Enter> >> d = c^(b+1) <Enter> >> who

Hiding Output Let us explore by doing exercises: >> clear; clc <Enter> >> whos <Enter> >> a = 3; <Enter> >> b = 2; <Enter> >> c = a * b; <Enter> >> d = c^(b+1); <Enter> >> who <Enter> >> % a, b, c, d are in workspace<enter> >> a, b, c, d <Enter>

Plot y versus x Introduction to plotting & displaying data: >> clear; clc <Enter> >> x = 0:0.1:1; <Enter> >> y = x.^2; <Enter> >> whos <Enter> >> plot(x,y,x,y, o ) <Enter> >> disp(' '),disp('... x... y...'),disp([x y']) <Enter> >> x <Enter> >> y <Enter> >> % x and y are 1-by-11 arrays of numbers!

Write a Simple Program 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 <Enter> >> r = 6 <Enter> >> h = 12 <Enter> >> v = (pi.*r.^2.*h)./3 <Enter> >> whos <Enter>

Editor & M-Files An M-file in MATLAB is analogous to a txtfile in Microsoft Notepad. An M-file is created in MATLAB text editor. M-files: You can save your programs (i.e., list of executable commands) as M-files. You can reopen and modify your program. They are useful for debugging (correcting errors) as you develop your programs (your technical computing tools).

Comments in programs Every time you write a program to be saved, it is helpful for you to comment (i.e., describe) it well. To insert a comment on a line in the editor or in the Command Window, use the comment operator %, then type your comment. MATLAB: will not run lines that begin with the comment operator (in the editor comments appear in green). Comments Comments allow you (and others) to more easily understand your program. When your lines of code are easy to understand, your code will be easier to use later.

Artofwell-written written code A well-written program is like literature; it contains comments explaining: what your program requires as input. what the variables in the program represent. what your program computes and displays. It is useful for you to add a set of header comments that include the name of the program, your name (as the programmer), and the date the program was created or modified.

Saving code in an M-File Open the editor by: Entering the command edit in the command window. Or click the white-sheet-of-paper icon in the upper left hand corner directly below file. Now enter the lines of code to find the volume of a cone: rr = 4 h = 12 v = (pi.*r.^2.*h)./3 REMARK: If you save it, add header comments and comments explaining what the program does. After you have typed in the code, save it as cone.m.

Execute an M-file as a Command Now execute (or run) the program by pushing F5, or by typing on the command line >> cone <Enter> or by clicking the run button. (Note that the run button looks like a page with a down arrow to its left. It can be found below help on the toolbar of the edit window.) If you entered the code as written on the previous slide you will get an error! What went wrong? Repair your program (Change rr = 4 to r = 4.), save it, and run it again. Now change the height to 24, save and run your program again.

Summary MATLAB can be used like a hand calculator to do arithmetic. You can define (or assign) variables with numbers and expressions to do calculations l as illustrated by the volume-of-cone example. The advantage of saving programs as M-files is that you open it, make changes and/or execute it again without having to type it all over again. This concludes our overview of MATLAB and a taste of things to come!

Reading Assignment CHAPTERS 1 & 2