BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila.

Slides:



Advertisements
Similar presentations
Multidimensional Array
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Fall 2006AE6382 Design Computing1 Numeric Representation in a Computer Learning Objectives Understand how numbers are stored in a computer and how the.
MATLAB Basics CS 111 Introduction to Computing in Engineering and Science.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Introduction to MATLAB 3 November Instructor: Andy Newman Office Hours: Stop by room 306 (main building) whenever
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB.
Introduction to MATLAB 7 for Engineers
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
Introduction to 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.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
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.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
1 Chapter 1 MATLAB Primer This introductory chapter is relatively short and has as its main objective the introduction of MATLAB ® to the reader. This.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (2): MATLAB Environment (Chapter 1)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
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 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Input, Output, and Processing
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
1 MatLab Basics Jae Hoon Kim Department of Physics Kangwon National University It contains hundreds of commands to do mathematics. Graph functions, solve.
1. Exam Topics Difference between computers and calculators John creates a new device. It will compute the orbit of all the planets in the solar system.
26 - 3/20/2000AME 150L1 M ATLAB ® /20/2000AME 150L2 M ATLAB ® vs. Fortran Fortran Positives –First Compiler –Legacy Codes –Efficient Numerically.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
Intro to Excel - Session 2.11 Tutorial 2 - Session 2.1 Creating a Worksheet.
Introduction to Programming with RAPTOR
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
Getting Started with MATLAB (part 3) 1. Algebra, 2. Trig 3. The keyword ans 4. Clean up and suppress output: finalizing the software’s presentation 1.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Engineering Analysis – Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
>> x = [ ]; y = 2*x y = Arrays x and y are one dimensional arrays called vectors. In MATLAB all variables are arrays. They allow functions.
Expressions and Interactivity. 3.1 The cin Object.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Matlab for Engineers Matlab Environment Chapter 2.
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)
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Basic operations in Matlab EE 201.  Achieve Comprehension LOL of Matlab basic operations. Class Learning Objectives 2.
ECE 1304 Introduction to Electrical and Computer Engineering
Arithmetic Operations
ECE 1304 Introduction to Electrical and Computer Engineering
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Experiment No. (1) - an introduction to MATLAB
MATLAB Introduction MATLAB can be thought of as a powerful graphing calculator but with a lot more buttons! It is also a programming language, commands.
CS 111 Introduction to Computing in Engineering and Science
MATLAB (Lecture 2) BY:MAHA ALMOUSA.
MatLab Program Used to Calculate Interactive
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

BASICS OF MATLAB Engr.Mian Shahzad Iqbal Lecturer,Telecom Department University of Engineering & Technology Taxila

In this presentation … You will identify the different windows in the MATLAB desktop. You will learn some of the basics of programming in the MATLAB. You will learn to use MATLAB as an interactive calculator.

MATLAB interactive session

VARIABLES

A Variable in MATLAB is a symbol used to contain a value. A scalar variable is a variable that contains a single number. A global variable is that variable which is available in the workspace. Local variable is that variable which is created by a function and is not available outside the function. A string variable is composed of text (alphanumeric characters). Logical variables are the variables containing the logical values.

Predefined constants

The several predefined constants are listed in the table below CommandDescription ansTemporary variable containing the most recent answer. epsSpecifies the accuracy of floating point precision. i,jThe imaginary unit InfInfinity piThe number 3.14 NaNIndicates an undefined numerical result

SCALAR OPERATIONS

Different operations that MATLAB performs on the scalars are listed, in their order of precedence, in the table below symbolOperationMATLAB form ^Exponentiation a b a^b *Multiplication aba*b /Right division a/ba/b \Left division b/aa\b +Addition a + ba+b -Subtraction a - ba-b

The assignment operator

The = sign in MATLAB is called the assignment or replacement operator. It is used to assign the numerical values to different variables in MATLAB. The variable on the left-hand side of the = operator is replaced by the right- hand side. General rules of using the = operator.

Managing the work session

1.clc clears the command window 2.clear Removes all variables from the memory. 3.clear var1 var2 Removes the variables var1 and var2 from the memory. 4.exist (‘name’) Determines if a file or variable exists having the name ‘name’. A 1 indicates that a variable exists and 0 indicates variable does not exists. 5.quit stops MATLAB. 6.who List the variables currently in the memory. 7.whos List the current variables and sizes, and indicates if they have the imaginary parts.

8.: Generates an array having regularly spaced elements. 9., separates elements of an array. separates several commands on the same line. 10.; Suppresses screen printing. Denotes a new row in an array. 11.… continues a line 12.Arrow and control keys. 13.Smart recall. 14.Tab completion.

COMPLEX NUMBER OPERATIONS

MATLAB handels complex number algebra automatically. For example, c 1 = 1- 2i is entered as follow c1 = 1-2i Common errors

Formatting commands

Table below gives many variants of the format command CommandsDescription and example. format shortFour decimal digits (the default); format long16 digits; format short eFive digits (four decimals) plus exponent; e+03. format long e 16 digits(15 decimals) plus exponent; e-04. format bankTwo decimal digits; format +Positive, negative or zero; +. format ratRational approximations; 43/7. format compactSuppresses some line feeds. format Resets to less compact display.

FUNCTIONS

The table below lists some of the built- in functions of the MATLAB FunctionMATLAB syntax exex exp(x) sqrt (x) ln xlog(x) log10xLog10(x) cos xcos(x) sin xsin(x) tan xtan(x) cos -1 xacos(x) sin -1 xasin(x) tan -1 xatan(x)