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

Program No. 1: Table1.1: Matlab Window

This document provides an introduction to MATLAB including: - MATLAB was originally created to provide access to matrix software and is a high-performance technical computing language. - The MATLAB desktop interface contains tools like the command window, figure window, editor window and more. - MATLAB allows basic arithmetic operations and creating variables through assignment. - MATLAB contains many built-in mathematical functions for tasks like trigonometry, exponents, logarithms and more. - Basic plotting in MATLAB involves using the plot command to connect x and y coordinate points on a graph. - Example programs are provided to plot common signals like steps, impulses, ramps, sines and cosines.

Uploaded by

Moni Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Program No. 1: Table1.1: Matlab Window

This document provides an introduction to MATLAB including: - MATLAB was originally created to provide access to matrix software and is a high-performance technical computing language. - The MATLAB desktop interface contains tools like the command window, figure window, editor window and more. - MATLAB allows basic arithmetic operations and creating variables through assignment. - MATLAB contains many built-in mathematical functions for tasks like trigonometry, exponents, logarithms and more. - Basic plotting in MATLAB involves using the plot command to connect x and y coordinate points on a graph. - Example programs are provided to plot common signals like steps, impulses, ramps, sines and cosines.

Uploaded by

Moni Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Program No.

1
AIM: Introduction to MATLAB
The name MATLAB stands for MATRIX
LABORATORY.
MATLAB was written originally to provide easy access to matrix
software developed by the LINPACK (linear system package) and
EISPACK (Eigen system package) projects.
MATLAB is a high-performance language for technical computing. It
integrates computation, visualization, and programming environment.
Furthermore, MATLAB is a modern programming language
environment it has sophisticated data structures, contains built-in
editing and debugging tools, and supports object-oriented
programming. These factors make MATLAB an excellent tool for
teaching and research.
When you start MATLAB, a special window called the MATLAB
desktop appears. The desktop is a window that contains other
windows. The major tools within or accessible from the desktop are:
TABLE1.1: MATLAB WINDOW

Window
Command Window
Figure Window
Editor Window
Help Window
Command History Window
Workspace Window
Current Folder Window

Purpose
Main window, enter variable, runs
programs.
Contains output from graphic
command.
Creates and debugs script and
function files.
Provide help information.
Logs commands entered in the
command window.
Provide the information about the
variables that are used.
Shows the files in the current
folder.

Basic Arithmetic operation


Table 1.2 gives the partial list of arithmetic operators.
Table 1.2: Basic Arithmetic Operators

Symbol
+
*
/
^

Operation
Addition
Subtraction
Multiplication
Division
Exponentiation

Example
2+3
2-3
2*3
2/3
2^3

Creating MATLAB Variables


MATLAB variables are created with an assignment statement. The
syntax of variable assignment is
variable name = a value (or an expression)
For example,
>> x = expression
where expression is a combination of numerical values, mathematical
operators, variables, and function calls. On other words, expression
can involve:
manual entry
built-in functions
user-defined functions
Miscellaneous commands
Here are few additional useful commands:
To clear the Command Window, type clc
To abort a MATLAB computation, type ctrl-c
To continue a line, type . . .
Mathematical functions

MATLAB offer many predefined mathematical functions for technical


computing which contains a large set of mathematical functions.
There is a long list of mathematical functions that are built into
MATLAB. These functions are called built-ins. Many standard
mathematical functions, such as sin(x), cos(x), tan(x), ex, ln(x), are
evaluated by the functions sin, cos, tan, exp, and log respectively in
MATLAB.
Table 1.2 lists some commonly used functions, where variables x and
y can be numbers, vectors, or matrices.
Table 1.3: Elementary functions

cos(x) Cosine
sin(x) Sine
tan(x) Tangent
acos(x) Arc cosine
asin(x) Arc sine
atan(x) Arc tangent
exp(x) Exponential
sqrt(x) Square root
log(x) Natural logarithm
log10(x) Common logarithm

abs(x) Absolute value


sign(x) Signum function
max(x) Maximum value
min(x) Minimum value
ceil(x) Round towards +1
floor(x) Round towards 1
round(x) Round to nearest integer
rem(x) Remainder after division
angle(x) Phase angle
conj(x) Complex conjugate

In addition to the elementary functions, MATLAB includes a number


of predefined constant values. A list of the most common values is
given in Table 1.3.
Table 1.4 : Predefined constant values

pi =The number 3:14159 : : :


i,j =The imaginary unit , which is 0+1.0000i.
eps=the smallest difference btw two numbers.
Inf = Used for infinity
NaN= Stands for Not a number
Creating simple plots
The basic MATLAB graphing procedure, for example in 2D, is to take
a vector of x-coordinates, x = (x1; : : : ; xN), and a vector of ycoordinates, y = (y1; : : : ; yN), locate the points (xi; yi), with
i=
1; 2; : : : ; n and then join them by straight lines. You need to prepare
x and y in an identical array form; namely, x and y are both row arrays
or column arrays of the same length.
The MATLAB command to plot a graph is plot(x,y). The plot
functions has different forms depending on the input arguments. If y
is a vector plot(y)produces a piecewise linear graph of the elements of
y versus the index of the elements of y. If we specify two vectors, as
mentioned above, plot(x,y) produces a graph
of y versus x.

The following commands are useful when plotting:


Table 1.5: Plotting commands

Graphing functions
Label the horizontal axis
Label the vertical axis
Attach a title to the plot
Change the limits on the x and y axis
Keep plotting in the same window.
Turn off the Keep plotting in the same window
command

MATLAB command
Xlabel (text)
Ylabel (text)
Title (text)
Axis ([xmin, xmax
ymin ymax])
hold on
hold off

PROGRAM NO: -2.


AIM: Write a program to plot 1. Impulse Function 2.Unit step
function 3. Unit ramp function
Program :
clc;

clear all;
close all;
N=30;
n=-N:1:N;
x=[zeros(1,N+1) ones(1,N)]
subplot(2,3,1),plot(n,x,'green');
xlabel('Time');
ylabel('Amplitude');
title('unit Step');
n=-N:1:N
x1=[zeros(1,N) ones(1,1) zeros(1,N)];
subplot(2,3,2),plot(n,x1,'red');
xlabel('Time');
ylabel('Amplitude');
title('unit Impluse');
a=1:N
x2=[zeros(1,N+1),a];
subplot(2,3,3),plot(n,x2,'yellow');
xlabel('Time');
ylabel('Amplitude');
title('unit Ramp');
n=-N:1:N;
x=[zeros(1,N+1) ones(1,N)]
subplot(2,3,4),stem(n,x,'green');
xlabel('Time');
ylabel('Amplitude');
title('unit Step');
n=-N:1:N
x1=[zeros(1,N) ones(1,1) zeros(1,N)];
subplot(2,3,5),stem(n,x1,'red');
xlabel('Time');
ylabel('Amplitude');
title('unit Impluse');
a=1:N
x2=[zeros(1,N+1),a];
subplot(2,3,6),stem(n,x2,'yellow');
xlabel('Time');

ylabel('Amplitude');
title('unit Ramp');

0utput:

Program:3
AIM: Write a program to plot sine wave and cosine wave.
Program:
clc;
clear all;

close all;
f=input('enter the frequency in Hz');
t=0:.0001:5;
y=sin(2*pi*f*t);
subplot(1,2,1);
plot(t,y);
ylabel('amplitude');
xlabel('time index');
title('sine wave')
f=input('enter the frequency in Hz');
t=0:.0001:5;
y=cos(2*pi*f*t);
subplot(1,2,2);
plot(t,y);
ylabel('amplitude');
xlabel('time index');
title('cosine wave')

Output:

Lab manual
For
signal and system
programs
1. Introduction to MATLAB
2. To plot basic signals
3. To plot complex exponential
& real sinusoids

Submitted to

Submitted by

Mrs. Deepti choudhary

Kavita devi

Ece department

251551002

You might also like