MATLAB Programming. Why MATLAB is used ? It can use a simple instruction to compute a very complex mathematical function. It provides high resolution.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to Matlab
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Introduction to Matlab II EE 2303 Lab. Basic Matlab Review Data file input/output string, char, double, struct  Types of variables load, save  directory/workspace.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
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.
Prof. R. Willingale Department of Physics and Astronomy 2nd Year C+R 2 nd Year C and R Workshop Part of module PA2930 – 2.5 credits Venue: Computer terminal.
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.
Digital Image Processing Lecture3: Introduction to MATLAB.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
MATLAB File Management. MATLAB User File Management Matlab provides a group of commands to manage user files. For more information, type help iofun. pwd.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
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.
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.
Introduction to Robo Pro
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.
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.
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Eng Ship Structures 1 Introduction to Matlab.
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.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
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.
CMPS 1371 Introduction to Computing for Engineers MatLab.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Introduction to MATLAB Session 1 Simopekka Vänskä, THL 2010.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Digital Image Processing Lecture4: Fundamentals. Digital Image Representation An image can be defined as a two- dimensional function, f(x,y), where x.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful 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”
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 Section2, statistics course Third year biomedical dept. Dina El Kholy, Ahmed Dalal.
Today we will learn MATLAB Click Start  All programm  Class Software  Matlab This command window will be seen with a prompt sign >> Any command can.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
訊號與系統 廖文淵 德霖技術學院資訊工程系 Introduction to MATLAB.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
2016/2/9System Arch (Fire Tom Wada)1 SCILAB Glance and demonstration By: Pham Thi Thu Phuong.
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)
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.
Lecture: MATLAB Chapter 1 Introduction
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Computers: Hardware and Software
Use of Mathematics using Technology (Maltlab)
Digital Image Processing
Matlab Basic Dr. Imtiaz Hussain
Experiment No. (1) - an introduction to MATLAB
Computer Simulation Lab
Presentation transcript:

MATLAB Programming

Why MATLAB is used ? It can use a simple instruction to compute a very complex mathematical function. It provides high resolution two dimensional and three dimensional graphic plot functions for signal analysis.

Why MATLAB is used ? It can play the sound and display an image in a personal computer or a workstation locally or from the computer network with the X window interface. MATLAB programs are portable in many computer systems.

Why MATLAB is used ? It provides interface with the programming language C to enhance its programming ability and execution speed. We can write a simple program easily to simulate an application which might takes many hours or many days in C or Fortran.

1.MATLAB is very suitable for signal processing. MATLAB programs is portable to any computer if it is installed with MATLAB and its tool-boxes. Once you initiate MATLAB software you see a prompt >> to indicate that MATLAB is waiting for your command. Each command can be interpreted as soon as you type in. To understand a command you can type help name, where name is the name of a command. For example, >> help sinc

MATLAB will output the information about the sinc function. A variable in MATLAB can be a scalar, a vector or a matrix; For example, >> x = 3 x = 3 >> y = 1:5 y =

>> z=[1:3;4:6;7:9] z =

2.To understand the variables in the MATLAB environment you can type whos to access their information. For example, >> whos Name Size Elements Bytes Density Complex x 1 by Full No y 1 by Full No z 1 by Full No Grand total is 15 elements using 120 bytes

3.MATLAB provides the following arithmetic operators to compute the arithmetic operations between a and b. There are several cases that

the following operations are valid: (a) both a and b are scalar. (b) a is a vector or a matrix and b is scalar. (c) both a and b are vectors or matrixes with the same dimension.

For example, >> a = 5; >> b = 2; >> a+b ans = 7 >> z z =

>> a+z ans = >> a*z ans =

>> z*z ans = >> z^2 ans =

4.MATLAB provides the following logic operators to compute the logic operations between a and b, where a and b must have the same dimension. >> a = [0 1] a = 0 1

>> b = ~a b = 1 0 >> a & b ans = 0 0 >> a | b ans = 1 1 >> a == b ans = 0 0

5.MATLAB provides the following array operators to compute the array operations between a and b, where a and b must have the same dimension. a = 1 2 >> b = [2,3] b = 2 3

>> a.^ b ans = 1 8 >> a.* b ans = 2 6 >> a./b ans =

The following program plots 1 Hz cosine signal cos(2  t). Actually, it’s digital signal. However, we can look it as a real-value analog signal. t = - 1:0.01:1; y = cos(2 * pi * t); fig; plot(t,y); xlabel(‘t’); ylabel(‘f(t)’); set(gca, ‘Ylim’,[ - 2,2]); print -deps cos1

Suppose the filename of the program is cos1.m you type cos1 to execute the program. For example, >> cos1

6.MATLAB provides the following instructions for triangular, hyperbolic, exponential and logarithmic functions,

Note that the function atan2(b,a) requires two variables and returns a value in [ - ,  ] and atan(t) just requires one variable returns a value in [ -  /2,  /2]. atan( - 0.5) ans = - atan2( - 1,2) ans = -

atan2(1, - 2) ans = atan(0.5) ans = atan2(1,2) ans = atan2( - 1, - 2) ans = -

7.MATLAB provides the following special operations to for a complex valued signal.

8.MATLAB provides the following special operations to round a real number.

9.If a complex can be computed in MATLAB. For example, a = sqrt( - 1) a = i exp(a) ans = i

10.The instruction save test store all variables in the file called test.mat. The instruction load test retrieves all variable from test.mat x = 1 y = 2 z = 3 % Save all variable in test.mat save test % Clear the workspace clear

% Check all variables are retrieved or not ? load test x y z % Save x and y in test.mat save test x y % Clear the workspace clear % Check all variables are retrieved or not ? load test x y

11.A sound file can be stored in the mat-file. Usually, it has two variables Fs and y, where Fs is the sampling rate and the variable y contains the sound signal. To load the sound file sound.mat and plot and play the sound in the following program can be used: load sound % The duration of the sound in second t = (1:length(y))/Fs; % Plot the sound Plot(t,y)

% Play the sound sound(y,Fs) In the Unix system there are several mat-files in the directory called /usr/local/matlab4.2c/to These sound files can be retrieved and played.

12.The contents of the current figure can be saved as a file with the following instruction: (a) print -dps filename (b) print -dpsc filename (c) print -deps filename (d) print -depsc filename to save a black and white postscript file, a color postscript file, a block and white encapsulated postscript file and a color encapsulated postscript file.

13.The instruction ezplot(f) plots the function f, where f is a symbolic expression with the variable t and t  [ - 2 , 2  ]. The instruction ezplot(f,[t 1,t 2 ]) plots the function f(t), where t  [t 1,t 2 ]. The instruction ezplot(f, [t 1,t 2 ],fig) plots the function f(t), where t  [t 1,t 2 ], with the figure number fig. f = ‘x^3’ ezplot(f); ezplot(f,[0,1000])

14.The absolute value of x can be computed as y = ‘(x^2)^(1/2)’ ezplot(y)

15. The function tri(t), rec(t), u(t), f(t)= |t| can not be defined symbolically. Therefore, it is difficult to use the instruction ezplot to plot these function. In the following program listing there are three main programs called unit.m, rec1.m and tri1.m and there are two functions called rec.m and tri,m.Figure 1.7, 1.8 and 1.9 are plotted by the commands unit, rec1 and tri1, respectively.