15
Introduction to Introduction to Matlab Matlab EE 2303 Lab

Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB: Mathematical Calculations Data Analysis & Visualization

Embed Size (px)

Citation preview

Page 1: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Introduction to MatlabIntroduction to Matlab

EE 2303 Lab

Page 2: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

MATLAB stands for “Matrix Laboratory”

APPLICATIONS OF MATLAB: Mathematical Calculations Data Analysis & Visualization Software Development Simulation

Welcome MatlabMatlabto

Page 3: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Getting StartedGetting Started

Command-Window

Workspace & Directory

Command- History

Page 4: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

How to Open Matlab Editor????How to Open Matlab Editor????

FILE

NEW

M-FILE

Page 5: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Basic Matlab Commands

clear all: clears workspace of all variables

close all : closes all the figure windows plot (x,y) : plots vector “y” versus “x” % : used for Comments help : when used with command gives its

syntax

Page 6: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

“help” Command

Page 7: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Basic Arithmetic Operators

+ : Arithmetic addition

- : Arithmetic subtraction

* : Arithmetic multiplication

/ : Arithmetic division

^ : Exponent or power

.* : (element by element for arrays)

Page 8: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Built-in Waveform Functions

cos (): Generates a cosine wave sin() : Generates a sine wave square(): Generates a square wave square( ,duty): Generates a square with

specified duty cycle sawtooth(): Generates a sawtooth wave sawtooth(t,0.5): Generates a triangle wave

Page 9: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Sine-wave Generationclear all;close all;frequency=1000; timeperiod=1/frequency;amplitude=1; dcoffset=0; t=0:0.00001:2*timeperiod; out=dcoffset+amplitude*cos(2*pi*frequency*t); plot(t,out);

Page 10: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Sine-wave Generation clear all; close all; frequency=1000; timeperiod=1/frequency; amplitude=1; dcoffset=0; t=0:0.00001:2*timeperiod; out=dcoffset+amplitude*cos(2*pi*frequency*t); plot(t,out);

Page 11: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

How to Execute the code???

Select all Right Click Evaluate Selection Debug RUN

Press F5

Type File name in Command window and press “Enter”

Page 12: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Simulated Wave forms

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

x 10-3

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Page 13: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

Square wave Generationclear all;close all;frequency=1000; timeperiod=1/frequency;amplitude=1; dcoffset=0; t=0:0.00001:2*timeperiod; out=dcoffset+amplitude*square(2*pi*frequency*t); plot(t,out);

Page 14: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

More Commands

xlabel(‘ ’) : Allows you to label x-axisylabel(‘ ‘) : Allows you to label y-axistitle(‘ ‘) : Allows you to give title for plot subplot() : Allows you to create multiple

plots in the same window

Page 15: Introduction to Matlab EE 2303 Lab. MATLAB stands for “Matrix Laboratory” APPLICATIONS OF MATLAB:  Mathematical Calculations  Data Analysis & Visualization

TIME FOR QUIZZ