BEH.420 Matlab Tutorial Bambang Adiwijaya 09/20/01.

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

MATLAB EXAMPLES Initial-value problems
Intro to modeling April Part of the course: Introduction to biological modeling 1.Intro to modeling 2.Intro to biological modeling (Floor) 3.Modeling.
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 Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Differential Equations Math Review with Matlab: Finding Solutions to Differential Equations S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department.
Data mining and statistical learning - lecture 6
Introduction to Matlab. I use Matlab for: Data analysis Data plotting Image Analysis Also – Simulations (solving odes/pdes/finite element methods) – Minimisations,
Soft Computing 1 Matlab Tutorial Kai Goebel, Bill Cheetham RPI/GE CRD
Exam #3 Review: Comprehensive Exam Class 14.2 Palm Matlab Book Ch. 1-5.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Implicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Ordinary Differential Equations (ODEs) 1Daniel Baur / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Daniel Baur ETH Zurich, Institut.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
Analytical vs. Numerical Minimization Each experimental data point, l, has an error, ε l, associated with it ‣ Difference between the experimentally measured.
Solving Systems of 3 or More Variables Why a Matrix? In previous math classes you solved systems of two linear equations using the following method:
Application of Differential Applied Optimization Problems.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Hydroinformatics: Session4 Dr Ivan Stoianov Room 328B Dr Andrew Ireson (Room 304) Mr Juan Rodriguez-Sanchez (411A) Mr Baback.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Chapter 4 "Inheritance" Inheritance is a powerful feature that allows the reuse of code. However, be sure that functions applied to objects created at.
OUTLINE Overview Numbers, variables and similar in Matlab
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Ordinary Differential Equations (ODEs) 1Michael Sokolov / Numerical Methods for Chemical Engineers / Explicit ODE Solvers Michael Sokolov ETH Zurich, Institut.
ACSL, POSTECH1 MATLAB 입문 CHAPTER 8 Numerical calculus and differential equations.
Chapter 10 ordinary differential equations (ODEs) Chapter 11 systems of ODEs (6 th edition)
1-d Arrays & Plotting.
Introduction To Matlab Class 4 Instructors: Hristiyan (Chris) Kourtev and Xiaotao Su, PhD Double click the matlab icon When prompted click “Skip”
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
MODEL FITTING jiangyushan. Introduction The goal of model fitting is to choose values for the parameters in a function to best describe a set of data.
Project and presentation preparation Applied Math 115 Practice your presentation, stay on schedule Correct organization: a brief introduction and motivation,
Matlab Tutorial 1 David Goldstein University of Colorado Dept of Aerospace Engineering Sciences.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
Higher Maths 2 4 Circles1. Distance Between Two Points 2Higher Maths 2 4 Circles The Distance Formula d =d = ( y2 – y1)²( y2 – y1)² + ( x2 – x1)²( x2.
EGR 115 Introduction to Computing for Engineers Loops and Vectorization – Part 3 Friday 17 Oct 2014 EGR 115 Introduction to Computing for Engineers.
ENG004 ALGORITHMS & INT. TO PROGRAMMING Week 4 “Arrays and Matrix Operations III” Ahmet Anıl Dindar
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
Beginning Programming for Engineers Animation. Special matrix functions >> clear >> ones(2,3) >> zeros(3,5) >> ones(2) >> zeros(3) >> eye(4) >> magic(4)
Section 9.4 – Solving Differential Equations Symbolically Separation of Variables.
CMPSC 200 Fall 2013 Lecture 37 November 18, 2013.
Introduction to Matlab
Introduction to Programming for Mechanical Engineers
Computer Application in Engineering Design
Introduction Mathcad is a product of mathSoft inc. The Mathcad can help us to calculate, graph, and communicate technical ideas. It lets us work with.
MATLAB DENC 2533 ECADD LAB 9.
(Mohammed Sami) Ashhab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Matlab review Matlab is a numerical analysis system
ENGG 1801 Engineering Computing
Use of Mathematics using Technology (Maltlab)
MATLAB Tutorial Dr. David W. Graham.
MATH My research interests lie primarily in the area of numerical analysis and scientific computing, …
ME 123 Computer Applications I Lecture 24: Character Strings 4/18/03
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
MATH My research interests lie primarily in the area of numerical analysis and scientific computing, …
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Coordinate Transformation in 3D Final Project Presentation
Matlab Basics Tutorial
ME 123 Computer Applications I Lecture 25: MATLAB Overview 4/28/03
Presentation transcript:

BEH.420 Matlab Tutorial Bambang Adiwijaya 09/20/01

Starting Matlab On athena: –Athena% add matlab –Athena% matlab On PC: –Point and click

Matlab basic Functions: –Matrix formulation: fast calculation –Strong in numerical, but weak in analytical –General purpose math solvers: nonlinear equations, ODEs, PDEs, optimization Basic mode of usage: –Interactive mode –M-script –Functions M-script and Functions must be written in separate files

Basic Syntax Case sensitive variable name Ending a statement with a “;” Vector: Vec(i) Matrix: Mat(i,j,…) Element by element matrix operations: –“.*,./,.^2” General matrix operations: –Cross product (*) Looping in matlab: for I = 1:N, for J = 1:N, A(I,J) = 1/(I+J-1); end If statement: if I == J A(I,J) = 2; elseif abs(I-J) == 1 A(I,J) = -1; else A(I,J) = 0; end

Basic Matlab Commands Matlab commandsFunctions and descriptions help functionnameMatlab on-line help for functions lookfor searchphraseTo find matlab function with descriptions containing the search phrase whoTo list all variables currently used size(matrix)To identify the dimensionality of the matrix ones(m,n)To create a unit matrix of size m x n print –depsc filename.psTo print an active plot (later use lpr to print in athena)

Function A function must be created under a separate file Function name and filename should be the same Example: function [res] = no1fun(x,p1); res(1)=x(1)*x(2)-p1; res(2)=x(1)-2*x(2);

Plotting figure; %to create a new popup window plot(X,Y,'c+:‘); semilogx(X,Y,’bx-’); subplot(row,col,figno), title([‘example title’]); ylabel(‘temp’); xlabel(‘conc’); axis([minX maxX minY maxY]); Example: a=(1:10); b=a.^2; c=a.^0.5; figure; subplot(2,1,1), semilogx(a,b,’bx-’); subplot(2,1,2), plot(a,c, ‘rs:’);

Fsolve: solving nonlinear equations FSOLVE solves equations of the form: F(X)=0 where F and X may be vectors or matrices. Syntax: X=fsolve('FUN',X0,OPTIONS, P1,P2,...) Problem: Solve: x(1)*x(2)-3=0 x(1)-2*x(2)=0

ODE solvers: solving ordinary differential equations ODE23, ODE45, ODE113, ODE15S, ODE23S –ODE45: Runge Kutta (4,5) formula, best first try function –ODE23: Runge Kutta (2,3) formula. –ODE113: variable order Adams-Bashforth-Moulton PECE solver. More efficient when the function evaluation is expensive. Stiff vs non-stiff ODEs Function: solving y’=F(t,y). ODE file must be in the form of: dydt=F(t,y,flag,p) Syntax: [T,Y] = ode45('F',TSPAN,Y0,OPTIONS,P1,P2,...)

ODE solvers: how to solve higher order ODE? Example: how to solve: y’’+2y’+3=0? Answer: make substitution. Y1=y Y2=y’ New formulation: Y1’=Y2 Y2’=-2Y2-3

Curvefitting CURVEFIT solves problems of the form: min sum {(FUN(X,XDATA)-YDATA).^2} where FUN, XDATA and YDATA are X vectors. Syntax: X=curvefit('FUN',X,XDATA,YDATA,OPTIONS,'GRADFUN',P1,P2,..) Examples: Fit the following data into the following model and regress x parameters: ydata=p*x(1)+x(2)*exp(-xdata);

Importing data Textread, dlmread DLMREAD read ASCII delimited file. M = dlmread(FILENAME,DLM) TEXTREAD read text file in a certain format [A B] = textread(‘datafile','%f %f');