Lecture: MATLAB Chapter 1 Introduction

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Functions in MatLab Create a new folder on your Z:drive called MatLab_Class24 Start MatLab and change your current directory to MatLab_Class24 Topics:
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
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.
Data Types. Every program must deal with data The data is usually described as a certain type This type determines what you can do with the data and how.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
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.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Eng Ship Structures 1 Introduction to Matlab.
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.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
Lecture #5 Introduction to C++
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
Introduction to Matlab
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
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.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2012.
Introduction to Matlab
1 Programming a Computer Lecture Ten. 2 Outline  A quick introduction to the programming language C  Introduction to software packages: Matlab for numerical.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Software Engineering Algorithms, Compilers, & Lifecycle.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
Matlab Programming for Engineers
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to Matlab
Revision Lecture
EGR 115 Introduction to Computing for Engineers
Other Kinds of Arrays Chapter 11
Other Kinds of Arrays Chapter 11
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Introduction to MATLAB
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
(Mohammed Sami) Ashhab
MATLAB: Structures and File I/O
Introduction to MATLAB
Lecture 1: Introduction
Matlab review Matlab is a numerical analysis system
Use of Mathematics using Technology (Maltlab)
Lecture 2 Introduction to MATLAB
Digital Image Processing
Communication and Coding Theory Lab(CS491)
Introduction to Matlab
Matlab Intro.
CSE 307 Basics of Image Processing
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Experiment No. (1) - an introduction to MATLAB
Using Script Files and Managing Data
Simulation And Modeling
CS 111 Introduction to Computing in Engineering and Science
Matlab Intro.
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

Lecture: MATLAB Chapter 1 Introduction Dr. Khalid Kaabneh, Dr. Nidal Youssef

Introduction to MATLAB technical computing environment for numeric computation and visualization. MATLAB is an interactive matrix based system for scientific and engineering numeric computation and visualization. You can solve complex numerical problems in a fraction of the time required with a programming language such as Fortran or C The name MATLAB is derived from MATrix LABoratory Dr. Khalid Kaabneh, Dr. Nidal Youssef

Dr. Khalid Kaabneh, Dr. Nidal Youssef What is Matlab? Matlab is basically a high level language which has many specialized toolboxes for making things easier for us How high? Assembly High Level Languages such as C, Pascal etc. Matlab Dr. Khalid Kaabneh, Dr. Nidal Youssef

What are we interested in? Matlab is too broad for our purposes in this course. The features we are going to require is Matlab Command Line m-files functions mat-files Command execution like DOS command window Series of Matlab commands Input Output capability Data storage/ loading Dr. Khalid Kaabneh, Dr. Nidal Youssef

Dr. Khalid Kaabneh, Dr. Nidal Youssef Working Memory Command Window Command History Dr. Khalid Kaabneh, Dr. Nidal Youssef

Dr. Khalid Kaabneh, Dr. Nidal Youssef Variables No need for types. i.e., All variables are created with double precision unless specified and they are matrices. After these statements, the variables are 1x1 matrices with double precision int a; double b; float c; Example: >>x=5; >>x1=2; Dr. Khalid Kaabneh, Dr. Nidal Youssef

Dr. Khalid Kaabneh, Dr. Nidal Youssef Single Values The value of two variables can be added together, and the result displayed… >> A = 10 >> A + A …or the result can be stored in another variable >> B = A + A The value of the variable is accessed through it’s name..... Adding A to A adds the values in the variable A (here 10) therefore the result is 20 the result can be stored in a new variable, B, which you can see now has the value 20 Dr. Khalid Kaabneh, Dr. Nidal Youssef 7 7

Dr. Khalid Kaabneh, Dr. Nidal Youssef Single Values Can not do an assignment?? >> 15 = A Error>>>> …or the result can be an arithmetic operation >> A = 4 + 2 A = 6 The value of the variable is accessed through it’s name..... Adding A to A adds the values in the variable A (here 10) therefore the result is 20 the result can be stored in a new variable, B, which you can see now has the value 20 Dr. Khalid Kaabneh, Dr. Nidal Youssef 8 8

Dr. Khalid Kaabneh, Dr. Nidal Youssef Single Values If a variable in the working memory, then we Can do this: >> A = 32 A = 32 >> A = A + 18 … The value of the variable is accessed through it’s name..... Adding A to A adds the values in the variable A (here 10) therefore the result is 20 the result can be stored in a new variable, B, which you can see now has the value 20 Dr. Khalid Kaabneh, Dr. Nidal Youssef 9 9

Clear clear command will clear all variables. clear variablename clears out a particular variable Who will list the variables you have.

Number format >> format long >> 2 * sin(1.4) ans = 1.970899459976920 >> pi 3.141592653589793 >> format short 1.9709 3.1416

>> format loose >> 2^7 ans = 128 >> format compact

Dr. Khalid Kaabneh, Dr. Nidal Youssef Expressions in MATLAB Dr. Khalid Kaabneh, Dr. Nidal Youssef 13

Dr. Khalid Kaabneh, Dr. Nidal Youssef Expressions in MATLAB Operators usual set of arithmetic operators + - * / ^ a few special ones, e.g., *. /. \ usual set of logical operators: & | ~ Functions large library of built-in functions (e.q. sqrt, abs, sin) e.g., >> x = sqrt(a); Dr. Khalid Kaabneh, Dr. Nidal Youssef

Dr. Khalid Kaabneh, Dr. Nidal Youssef MatLab Operators >> 1 + 3 ans= 4 >> 3 * 4 12 >> 7 / 3 ans= 2.333 >> 7 ^ 3 343 Dr. Khalid Kaabneh, Dr. Nidal Youssef

assignment of variables ans = 5 >> a*b 6 Dr. Khalid Kaabneh, Dr. Nidal Youssef

Relational Operators <, <=, >, >=, ==, ~= compare corresponding elements of arrays with same dimensions if one is scalar, one is not, the scalar is compared with each element result is, element by element, 1 or 0

Relational Operators <, <=, >, >=, ==, ~= compare corresponding elements of arrays with same dimensions if one is scalar, one is not, the scalar is compared with each element result is element by element 1 or 0 » a = [2 3] a = 2 3 » b=[4,5] b = 4 5 » a > b ans = 0 0 » b > a ans = 1 1 » a > 2 ans = 0 1

Useful built-in functions save rand zeros min max load Remember to use the Matlab help command if you get stuck