MATLAB DENC 2533 ECADD LAB 9.

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
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB 7 for Engineers
Al-Amer An Introduction to MATLAB Dr. Samir Al-Amer Term 062.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to MATLAB
Digital Image Processing Lecture3: Introduction to MATLAB.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
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 Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
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.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
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.
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 MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
CMPS 1371 Introduction to Computing for Engineers MatLab.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
OUTLINE Overview Numbers, variables and similar in Matlab
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.
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”
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
Matlab Programming for Engineers
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB
Release Numbers MATLAB is updated regularly
Introduction to Matlab
Lecture: MATLAB Chapter 1 Introduction
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
2) Platform independent 3) Predefined functions
INTRODUCTION TO BASIC MATLAB
Introduction to Matlab
Matlab Workshop 9/22/2018.
Introduction To MATLAB
StatLab Matlab Workshop
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
MATLAB Tutorial Dr. David W. Graham.
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Lecture 2 Introduction to MATLAB
Digital Image Processing
Communication and Coding Theory Lab(CS491)
Introduction to MATLAB
Introduction to Matlab
INTRODUCTION TO MATLAB
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Simulation And Modelling
Matlab Basic Dr. Imtiaz Hussain
Experiment No. (1) - an introduction to MATLAB
CS 111 Introduction to Computing in Engineering and Science
Introduction to Matlab
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

MATLAB DENC 2533 ECADD LAB 9

OUTLINE INTRO MATLAB SYSTEM MATLAB WINDOW MATLAB IN MATHEMATICAL OPERATION GRAPHIC ON MATLAB MATLAB EDITOR FILE (M-file) PROGRAMMING IN MATLAB

Introduction MATLAB stand for MATrix LABoratory. High performance language for technical computing. It integrates computation, visualization and programming. Typical uses in: Math and computation Algorithm development Modeling, simulation and prototyping Data analysis, exploration and visualization Scientific and engineering graphics Application development

MATLAB System Development environment – command window, command history, editor, debugger, browsers for help, workspace file. MATLAB mathematical function library – function like sum, sine, cosine and complex arithmetic, matrix. MATLAB language – high level matrix/array language with control flow statements, functions, data structure, I/O. Graphics – presentation graphics, image processing, data visualization. MATLAB application program interface (API) – a library that allows to write C and FORTRAN programs that interact with MATLAB.

Starting MATLAB When you start MATLAB, 4 windows appear by default: MATLAB Command Window Current Directory Window Workspace Window Command History Window

1) MATLAB Command Window To communicate with MATLAB program, use MATLAB command window. MATLAB display the prompt (>> ) to indicate that it is ready to receive instructions.

ii) Current Directory Window It is much like a file manager window. Used to access files For example: file.m – it will open file in Matlab editor.

iii) Workspace Window Display the variables created in the command window Workspace refers to the names and values of any variable in use in the current work session.

Command History Window All the previous instruction/programming entered in MATLAB command window showed here You can double click and drag the command into the MATLAB command window or Matlab editor.

Entering Command and Expressions Example of command s in Matlab Command Window: >> x=[0:002:8]; >> y=5*sin(x); >> plot(x,y):   When you put semicolon (;) at the end of your command line, Matlab will not shows the answer of your commands/expressions. Example of mathematical expressions in Matlab prompt without semicolon(;) : >> 8/10 ans = 0.8000 >> 5*anw ans = 4

Variables A variable in Matlab is a symbol used to contain a value. When we do not specify a variable name for a result, Matlab uses the symbol ans as a temporary variable containing the most recent answer. Scalar variable: >> r=8/10 r = 0.8000 >> s=5*r s = 4 >> 3 + 9 ans = 12

Variables (cont.) Variable names must begin with a letter and must contain less than 32 characters; contain letter, digits, and underscore. Matlab is case-sensitive, the following names represent different variables: speed, Speed, SPEED. Special variables and built-in constants in matlab: ans, i , j, inf, NaN, pi

Scalar Arithmetic Operations: SYMBOL OPERATION MATLAB FORM + Addition: a + b a + b - Subtraction: a – b a – b * Multiplication: a b a*b / Right division: a/b a/b \ Left division: b\a b\a ^ Exponentiation: ab a^b

Commands for managing the MATLAB Operation clc Clear the command window clear Removes all variables from memory clear var1 Remove the var1 quit Stop matlab who List the variables currently in memory whos List current variable and its size in memory ; (semicolon) Indicate the ends of the rows of a matrix or use after statement to suppress printing : (colon) used to pick out selected rows, columns and elements of vectors, matrices, and arrays , separator % comment

Computing with MATLAB Matlab able to handle collection of numbers, called array. Example of array variable: >> x= [0 1 3 6]; % 4-sequence of array >> u= [0 1; 2 1]; % 2x2 matrix >> y= [0:0.01:2]; >> length (y); % check total number of sequence-y >> y(7); % check the value of y in array-7   Define polynomial x2 + 2x + 1, to find roots of the polynomial: >> a= [1, 2, 1]; >> roots (a) Answer: roots of a: x= -1 , x= -1  So, the polynomial a is (x+1)(x+1)

Computing with MATLAB (cont.) Built-in and User Defined Functions Function MATLAB Syntax ex exp (x) √x sqrt (x) ln x log (x) log10 x log10 (x) cos x cos (x) sin x sin (x) tan x Tan (x) cos-1 x acos (x) sin-1 x asin (x) tan-1 x atan (x)

Matlab Scripting files & the Editor/Debugger Matlab can perform operations in 2 ways: Using Matlab Command Window Using Editor/Debugger (.m file)

MATLAB Editor M-file (.m) All program and function files are saved using Matlab editor. Writing M-files will enhance your problem solving productivity since many MATLAB commands can be run from one file without having to enter each command one-by-one at the MATLAB prompt. This way, corrections and changes can be made in the M-file and re-run easily.  Using the MATLAB Script Editor (click FileNewM-file)

Plotting with Matlab/Graphics Matlab contains many powerful functions for easily creating plots of several different types. Try this session: >> x=[0:0.001:10]; >> y=sin(2*x); >> figure(1); >> plot(x,y); >> xlabel(‘paksi-x’), ylabel(‘paksi-y’); >> title(‘plot y=sin 2x’);

Plotting with Matlab/Graphics (cont.) Command MATLAB Operation figure Create a new graph/figure plot( x, y) Draw the graph title('text') Define a title for a graph xlabel('text') Define a x-axis for a graph ylabel('text') Define a y-axis for a graph grid Setting grid lines at graph stem (x,y) plot a graph in a discrete sequence format mesh (x,y,z) Plot graph in three dimensional plots

PROGRAMMING IN MATLAB Flow control: if statement if statements evaluates a logical expression and executes a group of statements when the expression is true. Eg: If A > B ‘greater’ elseif A < B ‘less’ elseif A == B ‘equal’ else ‘unknown error’ end

PROGRAMMING IN MATLAB (cont.) for statement - for loop repeats a group of statements a fixed, predetermined number of times. Eg: m = 0 for n = 3:32 m = m + n end m

PROGRAMMING IN MATLAB (cont.) while statement while loop repeats a group of statements an indefinite number of times under control of a logical condition. Eg: a = 0 b = 10 while b > a b = b – 1; end a b