Fundamentals of MATLAB Usage

Similar documents
MATH 3511 Basics of MATLAB

MATH 5520 Basics of MATLAB

Lecture 1: What is MATLAB?

Introduction to MATLAB for CSE390

Some elements for Matlab programming

Introduction to MATLAB

MATLAB and Numerical Analysis

Chapter 1 MATLAB Preliminaries

Teaching Manual Math 2131

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

MATLAB Lecture 1. Introduction to MATLAB

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

Matlab Tutorial, CDS

Matlab course at. P. Ciuciu 1,2. 1: CEA/NeuroSpin/LNAO 2: IFR49

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Lecture 2: Variables, Vectors and Matrices in MATLAB

Introduction to Matlab

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

The MATLAB system The MATLAB system consists of five main parts:

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Lecturer: Keyvan Dehmamy

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

Introduction to MatLab. Introduction to MatLab K. Craig 1

A General Introduction to Matlab

Introduction to Scientific and Engineering Computing, BIL108E. Karaman

short-reference.mht 1/ /WK/

Using Matlab in the Chemical Engineering Curriculum at the University of Tennessee. A Workshop presented by David Keffer August 17, 2001

Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017

A Quick Tutorial on MATLAB. Zeeshan Ali

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Programming in Mathematics. Mili I. Shah

Finding, Starting and Using Matlab

A QUICK INTRODUCTION TO MATLAB

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD

MATLAB BEGINNER S GUIDE

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

Matlab and Psychophysics Toolbox Seminar Part 1. Introduction to Matlab

Arithmetic and Logic Blocks

Script started on Thu 25 Aug :00:40 PM CDT

Entering the numbers in these two ways creates the same matrix A.

TUTORIAL 1 Introduction to Matrix Calculation using MATLAB TUTORIAL 1 INTRODUCTION TO MATRIX CALCULATION USING MATLAB

2.0 MATLAB Fundamentals

CS129: Introduction to Matlab (Code)

Part #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr

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

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA

Matlab (Matrix laboratory) is an interactive software system for numerical computations and graphics.

Primer on MATLAB (This update for v.6 courtesy Prof. Jim Hanson, Bucknell Univ., a former Cornell instructor in 241)

BRUNO WELFERT Arizona State University AND. R. Kent Nagle. University of South Florida. Edward B. Saff. Vanderbilt University. A.

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

Introduction to GNU-Octave

Stokes Modelling Workshop

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

A Guide to Using Some Basic MATLAB Functions

Dr Richard Greenaway

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed

Arrays and Matrix Operations

EL2310 Scientific Programming LAB1: MATLAB lab session. Patric Jensfelt

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations

Identity Matrix: >> eye(3) ans = Matrix of Ones: >> ones(2,3) ans =

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

Introduction to MATLAB

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

MATLAB Workshop Dr. M. T. Mustafa Department of Mathematical Sciences. Introductory remarks

LabVIEW MathScript Quick Reference

Getting Started with MATLAB

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

A very brief Matlab introduction

Introduction to MATLAB

EE 350. Continuous-Time Linear Systems. Recitation 1. 1

Online Technology Guide for Elementary Linear Algebra, 6e Larson/Falvo

Mathematics 4330/5344 #1 Matlab and Numerical Approximation

Part VI. Scientific Computing in Python. Alfredo Parra : Scripting with Python Compact Max-PlanckMarch 6-10,

Scientific Computing Lecture Series Introduction to MATLAB Programming

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Introduction to MATLAB

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

Introduction to MATLAB Practical 1

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

A GUIDE FOR USING MATLAB IN COMPUTER SCIENCE AND COMPUTER ENGINEERING TABLE OF CONTENTS

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

How to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands

! The MATLAB language

Learning from Data Introduction to Matlab

Chapter 1 Introduction to MATLAB

Introduction to Computer Programming with MATLAB Matlab Fundamentals. Selis Önel, PhD

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming

MATLAB Introductory Course Computer Exercise Session

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square

Introduction to MATLAB

Introduction to MATLAB

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group

MATLAB GUIDE UMD PHYS401 SPRING 2011

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

LAB 1 General MATLAB Information 1

1 Introduction to MATLAB

MATLAB Vocabulary. Gerald Recktenwald. Version 0.965, 25 February 2017

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Transcription:

수치해석기초 Fundamentals of MATLAB Usage 2008. 9 담당교수 : 주한규 joohan@snu.ac.kr, x9241, Rm 32-205 205 원자핵공학과 1

MATLAB Features MATLAB: Matrix Laboratory Process everything based on Matrix (array of numbers) Math and Computation ti Linear System Solve, Eigenvalue, Matrix Manipulation, etc. Integration, Root finding, Optimization (Minimization), etc. Graphics and Visualization 2D Graphics: XY, Contour; 3D Graphics: Surface, Mesh Lighting and Movie Programming Simple FORTRAN or C typing programming with No Need for Explicit Variable Declarations (No consideration on memory usage) Data Analysis Statistical Analysis and a Lot More 2

MATLAB Screen File Management Variables Command History Interactive ti Window 3

Entering Data and Basic Manipulation Semicolon or next line for row separation diag produces column vector Transpose Element Operation 4

Colon Operator Increment : alone in matrix element specification alone entire column or row A(:,4) 4th column of A, A(2,:) 2nd row vector 5

Operators X=A\b solves Ax=b where A is a Matrix and b is a column vector Element-wise Operation 6

Convenient Matrix Generation eye(n) for nxn identity matrix diag(v) for diagonal matrix who s elements are given in vector v of dimension n 7

Block Matrices scalar 16 added to all elements 8

Basic Internal Functions diag(a) - vector consisting of diagonal elements of Matrix A tril(a) - lower triangular matrix of A triu(a) - upper triangular matrix of A inv(a) - inverse matrix of A det(a) - determinant of A size(a) - size of A, e.g mxn rank(a) - rank of A rref(a) - reduced row echelon form of A length(v) - dimension i of vector v [V,D]=eig(A) - eigenvector (V) and eigenvalues (D) of A [L,U]=lu(A) - L, U Factors of A obtained after Gaussian Eli. whos - list all the current variables in memory clear A B C - remove A B C 9

Flow Control Conditional <= : less than or equal ~= : not equal & : and : or ~ :not Loop exit out of a loop 10

Input/Output Syntax Use Semicolon to suppress screen display of result! Continuation on next line Save and Load save magic.dat A B x y load magic.dat Formatted File I/O fin=fopen('ri.inp','r'); yref=zeros(nbg,ntemp) for ibg=1:nbg xbg(ibg)=fscanf(fin,'%g',1); yref(ibg,:)=fscanf(fin,'%g',ntemp); end Formart Specifieres %10.3f : floating point with 3 digits after decimal %10d : integer with a width of 10 colums %15.3e: exponetial fout=fopen('ri.out','w'); for ibg=1:nbg fprinft(fout,'%d %g\n',ibg,yref(ibg)); end 11

Output Display Patterns Generic Format Rational Number 12

2D Graph 13

2D Graphs 14

3-D Plots 15

Graphs with Light 16

M-file and Function Files M-file Script file containing series of commands having extension.m Use % to put comments for descriptive program Function File A file to define a function function [ri,phi]=risg(nw,x,w,xbg) ri=zeros(size(xbg,1),1); for iw=1:nw phi=xbg./(x(iw)+xbg); ri=ri+x(iw)*phi*w(iw); w(iw); end 17

Basic Functions help matlab\general - General purpose commands. matlab\elmat - Elementary matrices and matrix manipulation. matlab\elfun - Elementary math functions. matlab\specfun - Specialized math functions. matlab\matfun - Matrix functions - numerical linear algebra. matlab\datafun - Data analysis and Fourier transforms. matlab\polyfun - Interpolation and polynomials. matlab\datafun - Data analysis and Fourier transforms.solvers. matlab\funfun - Function functions and ODE solvers. matlab\sparfun - Sparse matrices. matlab\graph2d - Two dimensional graphs. matlab\graph3d - Three dimensional graphs. matlab\timefun - File input and output. matlab\iofun - File input and output. matlab\demos - Examples and demonstrations. matlab\general - General purpose commands. Managing the workspace. who - List current variables. whos - List current variables, long form. clear - Clear variables and functions from memory. load - Load workspace variables from disk. save - Save workspace variables to disk. matlab\elmat - Elementary matrices and matrix manipulation. Elementary matrices. zeros - Zeros array. ones - Ones array. eye - Identity matrix. rand - Uniformly distributed random numbers. randn - Normally distributed random numbers. Basic array information. size - Size of array. length - Length of vector. ndims - Number of dimensions. disp - Display matrix or text. Matrix manipulation. cat - Concatenate arrays. reshape - Change size. diag - Diagonal matrices and diagonals of matrix. tril - Extract lower triangular part. triu - Extract upper triangular part. find - Find indices of nonzero elements. Operating system commands. cd - Change current working directory. pwd - Show (print) current working directory. ls - List directory.! - Execute operating system command (see PUNCT). 18

Basic Functions matlab\elfun - Elementary math functions. Trigonometric. sin - Sine. sinh - Hyperbolic sine. cosd - Cosine of argument in degrees. cosh - Hyperbolic cosine. acos - Inverse cosine. acoth - Inverse hyperbolic cotangent. Exponential. exp - Exponential. log - Natural logarithm. log10 - Common (base 10) logarithm. sqrt - Square root. nthroot - Real n-th root of real numbers. Rounding and remainder. fix - Round towards zero. floor - Round towards minus infinity. ceil - Round towards plus infinity. round - Round towards nearest integer. mod - Modulus (signed remainder after division). rem - Remainder after division. sign - Signum. matlab\matfun - Matrix functions - numerical linear algebra. Matrix analysis. norm - Matrix or vector norm. rank - Matrix rank. det - Determinant. trace - Sum of diagonal elements. rref - Reduced row echelon form. Linear equations. \ and / - Linear equation solution; use "help slash". inv - Matrix inverse. cond - Condition number with respect to inversion. lu - LU factorization. Eigenvalues and singular values. eig - Eigenvalues and eigenvectors. poly - Characteristic polynomial. matlab\datafun - Data analysis and Fourier transforms. Basic operations. max - Largest component. min - Smallest component. mean - Average or mean value. std - Standard deviation. var - Variance. sort - Sort in ascending order. sum - Sum of elements. prod - Product of elements. 19

Basic Functions matlab\funfun - Function functions and ODE solvers. Optimization and root finding. fminsearch - Multidimensional unconstrained nonlinear minimization, by Nelder-Mead direct search method. fzero - Scalar nonlinear zero finding. Numerical integration (quadrature). quad - Numerically evaluate integral, low order method. quadl - Numerically evaluate integral, higher order method. matlab\sparfun - Sparse matrices. Full to sparse conversion. sparse - Create sparse matrix. full - Convert sparse matrix to full matrix. find - Find indices of nonzero elements. spy - Visualize sparsity pattern. matlab\graph2d - Two dimensional graphs. Elementary X-Y graphs. plot - Linear plot. loglog - Log-log scale plot. semilogx - Semi-log scale plot. semilogy - Semi-log scale plot. Axis control. axis - Control axis scaling and appearance. grid - Grid lines. box - Axis box. subplot - Create axes in tiled positions. Graph annotation. title - Graph title. xlabel - X-axis label. ylabel - Y-axis label. text - Text annotation. gtext - Place text with mouse. Hardcopy and printing. print - Print graph or Simulink system; or save graph to M-file. 20

Basic Functions matlab\graph3d - Three dimensional graphs. plot3 - Plot lines and points in 3- D space. mesh - 3-D mesh surface. surf - 3-D colored surface. fill3 - Filled 3-D polygons. Color control. colormap - Color look-up table. caxis - Pseudocolor axis scaling. Lighting. surfl - 3-D shaded surface with lighting. lighting - Lighting mode. Viewpoint control. view - 3-D graph viewpoint specification. rotate3d - Interactively rotate view of 3-D plot. Hardcopy and printing. vrml - Save graphics to VRML 2.0 file. matlab\iofun - output. File input and File opening and closing. fopen - Open file. fclose - Close file. Binary file I/O. fread - Read binary data from file. fwrite - Write binary data to file. matlab\timefun - Time and dates. Current date and time. now - Current date and time as date number. date - Current date as date string. clock - Current date and time as date vector. Timing functions. cputime - CPU time in seconds. etime - Elapsed time. pause - Wait in seconds. 21