0% found this document useful (0 votes)
138 views

MATLAB

This document provides an introduction to MATLAB. It discusses that MATLAB stands for Matrix Laboratory and its applications include mathematical calculations, data analysis/visualization, software development, and simulation. It describes the MATLAB workspace and command window. It provides examples of basic MATLAB commands like plot, clear all, close all, and help. It demonstrates how to generate sine waves, square waves, and other waveforms using built-in MATLAB functions. It also shows how to execute code, add labels and titles to plots, and create multiple plots in the same window using commands like subplot.

Uploaded by

11008592
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
138 views

MATLAB

This document provides an introduction to MATLAB. It discusses that MATLAB stands for Matrix Laboratory and its applications include mathematical calculations, data analysis/visualization, software development, and simulation. It describes the MATLAB workspace and command window. It provides examples of basic MATLAB commands like plot, clear all, close all, and help. It demonstrates how to generate sine waves, square waves, and other waveforms using built-in MATLAB functions. It also shows how to execute code, add labels and titles to plots, and create multiple plots in the same window using commands like subplot.

Uploaded by

11008592
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Introduction to Matlab

EE 2303 Lab
Welcome to Matlab
MATLAB stands for “Matrix Laboratory”

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

Workspace & Directory

Command-Window

Command- History
How to Open Matlab Editor????

FILE
NEW
M-FILE
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
“help” Command
Basic Arithmetic Operators
+ : Arithmetic addition
- : Arithmetic subtraction
* : Arithmetic multiplication
/ : Arithmetic division
^ : Exponent or power
.* : (element by element for arrays)
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
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);
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);
How to Execute the code???
Select all Right Click Evaluate
Selection
Debug RUN

Press F5

Type File name in Command window and


press “Enter”
Simulated Wave forms
1

0.8

0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
-3
x 10
Square wave Generation
clear 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);
More Commands
xlabel(‘ ’) : Allows you to label x-axis
ylabel(‘ ‘) : Allows you to label y-axis
title(‘ ‘) : Allows you to give title for
plot
subplot() : Allows you to create multiple

plots in the same window


TIME FOR QUIZZ

You might also like