MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.

Slides:



Advertisements
Similar presentations
Lecture 5.
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Welcome to EGR 106 Foundations of Engineering II Course information Today’s specific topics: – Computation and algorithms – M ATLAB Basics Demonstrations.
Introduction to MATLAB
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB.
Al-Amer An Introduction to MATLAB Dr. Samir Al-Amer Term 062.
Matlab Intro. Outline Matlab introduction Matlab elements Types Variables Matrices.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
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.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
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.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
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)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
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 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.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
CMPS 1371 Introduction to Computing for Engineers MatLab.
Basics of MATLAB By DR. Wafaa Shabana
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
1 DKT 211 Basic Communication Engineering LAB # 1A : (Lecture 1) Introduction to Matlab  Basic Features  Scientific features  Array Operations  Script.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
1 Lecture 1 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
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.
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB
2) Platform independent 3) Predefined functions
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
(Mohammed Sami) Ashhab
Introduction To MATLAB
EEE 244 Numerical Methods In Electrical Engineering
MATLAB PRIMER by Michael Medvinsky(2014)
Use of Mathematics using Technology (Maltlab)
Communication and Coding Theory Lab(CS491)
Matlab Intro.
INTRODUCTION TO MATLAB
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.
Simulation And Modelling
Experiment No. (1) - an introduction to MATLAB
Matlab Intro.
Presentation transcript:

MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods

Outline of the Talk 1 Introduction 2 Array and Files 3 Programming in Matlab 4 Importing and Exporting Data 5 Plots

MATLAB – A Computational Methods Introduction MATLAB is a program for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It’s name is derived from MATrix LABoratory. MATLAB has since been expanded and now has built-in functions for solving problems requiring data analysis, signal processing, optimization, and several other types of scientific computations. It also contains functions for 2-D and 3-D graphics and animation.

MATLAB – A Computational Methods Contd… MatLab : Matrix Laboratory Numerical Computations with matrices Every number can be represented as matrix Why Matlab? User Friendly (GUI) Easy to work with Powerful tools for complex mathematics

MATLAB – A Computational Methods Contd… Workspace Command History Command Window

MATLAB – A Computational Methods Array and Function Files MATLAB treats all variables as matrices. For our purposes a matrix can be thought of as an array, in fact, that is how it is stored. Vectors are special forms of matrices and contain only one row OR one column. Scalars are matrices with only one row AND one column MATLAB Matrices

MATLAB – A Computational Methods Contd… A matrix with only one row AND one column is a scalar. A scalar can be created in MATLAB as follows: » a_value=23 a_value = 23

MATLAB – A Computational Methods Contd… A matrix with only one row is called a row vector. A row vector can be created in MATLAB as follows (note the commas): » rowvec = [12, 14, 63] rowvec =

MATLAB – A Computational Methods Contd… A matrix with only one column is called a column vector. A column vector can be created in MATLAB as follows (note the semicolons): » colvec = [13 ; 45 ; -2] colvec =

MATLAB – A Computational Methods Contd… A matrix can be created in MATLAB as follows (note the commas AND semicolons): » matrix = [1, 2, 3 ; 4, 5,6 ; 7, 8, 9] matrix =

MATLAB – A Computational Methods Contd… a vectorx = [ ] x = transposey = x.’ y = a matrixx = [1 2 3; 5 1 4; ] x =

MATLAB – A Computational Methods Contd… x(i,j) subscription whole row y=x(2,3) y = 4 y=x(3,:) y = y=x(:,2) y = whole column

MATLAB – A Computational Methods Files Use predefined functions or write your own functions Reside on the current directory or the search path –add with File/Set Path Use the Editor/Debugger to edit, run MatLab Files (.m)

MATLAB – A Computational Methods Contd… Reading Data from files MATLAB supports reading an entire file and creating a matrix of the data with one statement. >> load mydata.dat;% loads file into matrix. % The matrix may be a scalar, a vector, or a % matrix with multiple rows and columns. The % matrix will be named mydata. >> size (mydata)% size will return the number % of rows and number of % columns in the matrix >> length (myvector)% length will return the total % no. of elements in myvector

MATLAB – A Computational Methods Programming in MATLAB MATLAB Variable Names Variable names ARE case sensitive Variable names can contain up to 63 characters (as of MATLAB 6.5 and newer) Variable names must start with a letter followed by letters, digits, and underscores.

MATLAB – A Computational Methods Contd… To get started, type one of these commands: A simple program » a=5; » b=a/2 b = »

Computational Methods MATLAB Contd… MATLAB symbols >>prompt...continue statement on next line,separate statements and data %start comment which ends at end of line ;(1)suppress output (2)used as a row separator in a matrix :specify range

Computational Methods MATLAB Contd… MATLAB Math & Assignment Operators OperatorSymbolSyntax Power ^ or.^a^ba.^b Multiplication * or.*a*ba.*b Division or / or./ \ or.\ a/b b\a a./b b.\a NOTE: 56/8 = 8\56

Computational Methods MATLAB Contd... - (unary) + (unary) OperatorSymbolSyntax Addition +a + b Subtraction -a - b Assignment =a = b (assign b to a )

MATLAB – A Computational Methods Contd… MATLAB Relational Operators MATLAB supports six relational operators. OperatorSymbol Less Than< Less Than or Equal<= Greater Than> Greater Than or Equal>= Equal To== Not Equal To~=

MATLAB – A Computational Methods Contd… MATLAB Logical Operators MATLAB supports three logical operators. OperatorSymbolPrecedence not~% highest precedence and&% equal precedence with or or |% equal precedence with and

Computational Methods MATLAB Contd… A for loop in MATLAB for i = 1:1:100 temp(1,i)=0; end A while loop in MATLAB while x <= 10 % execute these commands end

Computational Methods MATLAB Contd… Scalar - Matrix Addition » a=3; » b=[1, 2, 3;4, 5, 6] b = » c= b+a% Add a to each element of b c =

Computational Methods MATLAB Contd… Scalar - Matrix Multiplication » a=3; » b=[1, 2, 3; 4, 5, 6] b = » c = a * b % Multiply each element of b by a c =

Computational Methods MATLAB Importing and Exporting Data Importing Data into the Workspace The first step in analyzing data is to import it into the MATLAB workspace. See the topics under Importing Data for detailed information about supported data formats and the functions.Importing Data When you work with time series data, use the Time Series Tools GUI (tstool) to import the data and create timeseries objects. The Time Series Tools Import Wizard makes it easy to import or define a time vector for your data.tstool

Computational Methods MATLAB Contd… Exporting Data from the Workspace When you analyze your data, you might create new variables or modified imported variables. You can export variables from the MATLAB workspace to various file formats, both character-based and binary. You can, for example, create HDF and Excel files containing your data,

MATLAB – A Computational Methods Plots A plot is any graphic display you can create within a figure window. Plots can display tabular data, geometric objects, surface and image objects, and annotations such as titles, legends, and colorbars. Figures can contain any number of plots. Each plot is created within a 2-D or a 3-D data space called an axes.

Computational Methods MATLAB Contd… Plotting with MATLAB There are commands in MATLAB to "annotate" a plot to put on axis labels, titles, and legends. For example: >> % To put a label on the axes we would use: >> xlabel ('X-axis label') >> ylabel ('Y-axis label') >> % To put a title on the plot, we would use: >> title ('Title of my plot')

MATLAB – A Computational Methods Contd… x = 0:pi/100:2*pi; y = sin(x); plot(x,y) xlabel('x = 0:2\pi') ylabel('Sine of x') title('Plot of the Sine Function')

MATLAB – A Computational Methods Contd… Types of 2-D Graphs Line Graphs Bar Graphs Area Graphs Direction Graphs Radial Graphs Scatter Graphs

MATLAB – A Computational Methods Contd… 3-D Plots Here are some examples of surface plots in MATLAB. Mesh Plot of Peaks z=peaks(25); mesh(z); Colormap(hsv) Surface Plot of Peaks z=peaks(25); surf(z); colormap(jet); Contour Plot of Peaks z=peaks(25); contour(z,16); colormap(hsv)

MATLAB – A Computational Methods Applications of Matlab  Linear Algebra  Solving a linear system  Gaussian elimination  finding eigenvalues and eigenvectors  Matrix factorization  Curve Fitting and Interpolation  Polynomial curve fitting on the fly  Least squares curve fitting  Interpolation  Data Analysis and Statistics  Numerical Integration  Ordinary Differential Equations  Nonlinear Algebraic Equations  Graphs ( 2 D and 3 D)

MATLAB – A Computational Methods Contd… 3-D Plots Here are some examples of surface plots in MATLAB. Mesh Plot of Peaks z=peaks(25); mesh(z); Colormap(hsv) Surface Plot of Peaks z=peaks(25); surf(z); colormap(jet); Contour Plot of Peaks z=peaks(25); contour(z,16); colormap(hsv)

MATLAB – A Computational Methods THANK YOU!!! For any queries contact: