Basis of Mathematical Modeling LECTURE 1 Computation and visualization in MATLAB Dr. N.K. Sakhnenko, PhD, Professor Associate.

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

Introduction to MATLAB The language of Technical Computing.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to Matlab:
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MATLAB GRAPHICS 2-D.
Introduction to Matlab Tutorial for CS4MN3/SE3X03 Wen Yu McMaster University.
1 Introduction to MatLab MatLab stands for Matrix Laboratory. As the name suggests most of the programming operations have as input or output a matrix.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Matlab intro The Environment
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB Fundamentals.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
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 adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
You can make this in matlab!. Matlab Introduction and Matrices.
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.
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.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
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.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Basics of MATLAB By DR. Wafaa Shabana
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
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.
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
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.
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
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)
An Introduction to Programming in Matlab Emily Blumenthal
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
EEE 242 Computer Tools for Electrical Engineering
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
Session III Plotting in MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU MATLAB Tutorials.
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB
MatLab Programming By Kishan Kathiriya.
Ch3 Graphics Overview of Plotting Editing Plots
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
EEE 244 Numerical Methods In Electrical Engineering
StatLab Matlab Workshop
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Lecture 2 Introduction to MATLAB
Introduction to Matlab
Presentation transcript:

Basis of Mathematical Modeling LECTURE 1 Computation and visualization in MATLAB Dr. N.K. Sakhnenko, PhD, Professor Associate

Outline History Useful links and References Accessing MATLAB Matrices and Matrix Operations Two-Dimensional Graphics Three-Dimensional Graphics

Introduction / MATLAB, developed by The MathWorks, Inc., integrates computation, visualization and programming in MATLAB and companion toolboxes provide engineers, scientists, mathematicians, and educators with an environment for technical computing applications. These products serve a broad range of tasks across a variety of industries from automotive and electronics to industrial equipment and telecommunications.

History MATLAB was invented in the late 1970s by Cleve Moler, the chairman of the computer science department at the University of New Mexico. It soon spread to other universities and found a strong audience within the applied mathematics. Jack Little, an engineer, recognizing its commersial potential, joined with Moler. They founded The MathWorks in 1984 to continue its development. MATLAB was first adopted by control design engineers, but quickly spread to many other domains. It is now also used in education, in particular the teaching of linear algebra and numerical analysis, and is popular amongst scientists involved with image processing.

Useful links MATLAB related links, tools, libraries, and resources for scientists and engineers Matlab Demos. Free online books

References The MathWorks, Inc, MATLAB. Getting Started Guide. T. Davis and K. Sigmon, MATLAB Primer, Chapman & Hall\CRC, 2005 K. Chen, J. Giblin, A. Irving, Explorations with MATLAB, Cambridge University Press, 2006

Accessing MATLAB The MATLAB Desktop In Microsoft windows we can enter MATLAB with double-click on the MATLAB icon

Help window

MATLAB windows

Command Window The command window is where you can interact with MATLAB directly. Any output is immediately printed to the window. Expression and statements are usually of the form: variable=expression or simply: expression >> a=6-4 a =2 >> 1+2 ans =3 >> a*ans ans =6 If the variable name and = sign are omitted, a variable ans (for answer) is automatically created to which the result is assigned.

Matrices >> A=[1 2 3;0 1 -5;0 0 1] A = >> a=[1,2,4;5,0,-1;6,0,2] a = >> A(2,3) ans = -5 Entering a Matrix:  MATLAB is case-sensitive in the names of commands, functions and variables, so A and a are two different variables.  A coma or blank separates the elements within a row. A semicolon ends a row.  Individual matrix entries can be referenced with indices inside parentheses. MATLAB=Matrix Laboratory!!!

Matrix Operators The following matrix operators are available in MATLAB: + addition - subtraction * multiplication ^ power ‘ transpose \ left division / right division inv inversion det finding of the determinant

Systems of linear equations >> A=[ ; ; ]; >> b=[1.3; 3.9; 5.4]; >> x=inv(A)*b x = If the last character of a statement is a semicolon, display of the result is suppressed, but the assignment is carried out. This is essential in suppressing unwanted display of intermediate results.

How to control output All computations in MATLAB are done in double precision (about 15 digits accuracy). The format of the displayed output can be controlled by the following commands: FORMAT SHORT Scaled fixed point format with 5 digits FORMAT LONG Scaled fixed point format with 15 digits FORMAT SHORT E Floating point format with 5 digits FORMAT LONG E Floating point format with 15 digits FORMAT SHORT G Best of fixed or floating point format with 5 digits FORMAT LONG G Best of fixed or floating point format with 15 digits FORMAT BANK dollars and cents FORMAT SHORT is the default. Our can change output format with >File >Preferences

MATLAB functions MATLAB provides a large number of standard elementary mathematical functions. MATLAB also provides many more advanced mathematical functions. For a list of the elementary mathematical functions, type help elfun For a list of more advanced functions, type help specfun help elmat >> x=exp(-25)*log(7.4)/7 ; >> y=(sin(4.45*pi)+cos(3.78*pi))/tan(7) ; >> z=x+y^2 z =

Entry-by-entry operations Note that “.*” (dot-star) is for entry-by-entry multiplication; ”.^” (dot-power) is for entry-by-entry power. For example, either: [ ].*[ ] [ ].^2 will yield [ ]. Try it. Entry-by-entry operations are particularly useful using MATLAB graphics! The colon operator The colon “:” is used to generate matrixes. The expression [1:0.2:2] is a row vector

Two-Dimensional Graphics >>x=[0:0.05:2*pi]; >> y=sin(x.^2); >> plot(x,y); The plot command creates linear x-y plot, if x and y are vectors of the same length. Enter the command demo and select some of the visualization and graphics demos!

Two-Dimensional Graphics >> x1=[-2:0.01:-1]; >> y1=-2-x1; >> x2=[-1:0.01:1]; >> y2=x2; >> x3=[1:0.01:2]; >> y3=2-x3; >> x=[x1 x2 x3]; >> y=[y1 y2 y3]; >> plot(x,y)

Parametrically defined curves >> t=[0:0.01:4*pi]; >> x=t-sin(t); >> y=1-cos(t); >>plot(x,y);

Graphics in polar coordinates >> fi=[0:0.01:2*pi]; >> ro=3*(1-cos(fi)); >> polar(fi,ro);

Titles, labels, line types, marker types, colors The graphs can be given titles, axes labels and text placed within the graph with the following commands: title graph title xlabel x-axis label ylabel y-axis label

Two-Dimensional Graphic >>x=[0:pi/20:2*pi]; >> f1=cos(2*x); >> f2=cos(3*x); >> plot(x,f1,x,f2) >> grid on >> title('Figure 1') >> xlabel('x') >> ylabel('y') >> legend ('y=cos(2x)','y=cos(3x)')

Plotting multiple data sets in one graph >> x=[-2*pi:0.1:2*pi]; >> y1=cos(x); >> y2=cos(x).^2; >> y3=cos(x).^3; >> plot(x,y1,'r.',x,y2,'k:',x,y3,'--ok')

Subplots The command subplot(m,n,p) partitions a single figure into an m-by-n array of panes, and make pane p the current plot. The panes are numbered left to right. >> fi=[0:0.01:2*pi]; >> ro_1=(cos(3*fi)); >> subplot(2,2,1); >> polar(fi,ro_1); >> ro_2=(sin(3*fi)); >> subplot(2,2,2); >> polar(fi,ro_2); >> ro_3=(cos(5*fi)); >> subplot(2,2,3); >> polar(fi,ro_3); >> ro_4=(sin(5*fi)); >> subplot(2,2,4); >> polar(fi,ro_4);

Diagrams >> a=[ ]; >> b=[ ]; >> bar(a,b) >>x = [-2.9:0.2:2.9]; >>bar(x,exp(-x.*x))

Circular diagram >> c=[ ]; >> pie(c) Circular diagrams display the percentage that each element in a vector or matrix contributes to the sum of all elements.

Three-Dimensional Graphics >> [X,Y]=meshgrid(-3:0.1:3,-3:0.1:3); >> Z=sin(X)./(X.^2+Y.^2+0.3); >> mesh(X,Y,Z) >> surf(X,Y,Z) >> shading interp

Three-Dimensional Graphics >> [X,Y]=meshgrid(-1:0.05:1,0:0.05:1); >> Z=4*sin(2*pi*X).*cos(1.5*pi*Y).*(1-X.^2).*Y.*(1-Y); >> surf(X,Y,Z) >> shading interp >> contourf(X,Y,Z) >> colorbar contourf(Z) draws a contour plot of matrix Z, where Z is interpreted as heights with respect to a plane.

Three-Dimensional Graphics >> x = [-2:.2:2]; y = [-1:.2:1]; >> [xx,yy] = meshgrid(x,y); >> zz = xx.*exp(-xx.^2-yy.^2); >> mesh(xx,yy,zz) >> contour(xx,yy,zz) >> [px,py] = gradient(zz); >> quiver(x,y,px,py)

Homework