Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

FOUNDATION UNIVERSITY RAWALPINDI

CAMPUS
ELECTRICAL ENGINEERING DEPARTMENT
SIGNALS AND SYSTEMS (LAB)
LAB REPORT # 1
BASIC MATLAB COMMANDS

NAME: SHAH ZEB


REG # 067
SECTION: BSEE-4B
DATE: 15-10-2015
SUBMITTED TO: Eng. Adnan Khan

INTRODUCTION:
MATLAB stands for MATRIX LABORATORY. MATLAB is a high-performance
language for technical computing. It integrates computation, visualization, and
programming environment. 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.
MATLAB is an interactive system whose basic data element is an array
that does not require dimensioning.
It has powerful built-in routines that enable a very wide variety of
computations. It
Also has easy to use graphics commands that make the visualization of
results immediately available. Specific applications are collected in packages
referred to as toolbox. There are toolboxes for signal processing, symbolic
computation, control theory, simulation, optimization, and several other
fields of applied science and engineering.

MATLAB BASICS:
A. DEFINITION OF VARIABLES:
1. a = 1 + 2
Yields: a = 3

2. b = 2 * a;
Yields: b = 6

3. y = 2 * (1 + 4 * j)
Yields: 2.0000 + 8.0000i

4. y = 2 * (1 + 4 * j)
c = abs(y)
Yields: c = 8.2462
d = angle(y)
Yields: c = 1.3258

5. a = 3;
c = cos (a)
Yields: -0.9900
c= exp (a)

Yields: 20.0855

B. DEFINITION OF MATRICES:
1. v = [1 3 5 7]

2. v = [1 3 5 7];
v(5) = 8

3. v = [1 3 5 7];
a = [9 10];
b = [v a]
Yields: b = [1 3 5 7 9 10]

4. M =[1 2 4;3 6 8]
1 2 4
Yields: M = 3 6 8

5. a = [1 2 3];
b = [4 5 6];
c=a+b
Yields: c =

5 7 9

6. t = 0:10;
x = cos (2*t)
Yields: x = 1.0000 -0.4161 -0.6536
-0.9577 0.6603 0.4081

7. t = 0:10;
x = t.*cos(t)
Yields: x = 0 0.5403 -0.8323
-1.1640 -8.2002 -8.3907

C. PLOTTING

0.9602 -0.1455 -0.8391

-2.9700

-2.6146

1.4183

0.8439

5.7610

0.1367

5.2773

1. x = -1:0.01:2;
plot(x,x.^2)
xlabel('time(sec)')
ylabel('velocity')
title('Velocity-Time Graph')

2. x = 0:0.1:10;
plot(x,cos(x))
title('cosine graph')
xlabel('x')
ylabel('cos(x)')

3. x = 0:0.1:10;

plot(x,sin(x))
title('sine graph')
xlabel('x')
ylabel('sin(x)')

4. Multiple Curves and Text


x = 0:0.1:10;
plot(x,sin(x))
hold on
plot(x,cos(x))
hold off
title('sine and cosine graph')
xlabel('x')
ylabel('sin(x)/cos(x)')
text(3,0.2,'y=sin(x)')
text(5,0.2,'y=cos(x)')
grid

5. x = 0:0.1:10;
subplot (2,1,1),plot(x,sin(x))
title('sine graph')
xlabel('x')
ylabel('sin(x)')
grid
subplot(2,1,2),plot(x,cos(x))
title('cosine graph')
xlabel('x')
ylabel('cos(x)')
grid

6. t = 0 : 0.01 :10;
f = ('input frequency');
x = exp(2*t)
plot(t ,x)

7. x = 0:0.1:10;
subplot (3,1,1),plot(x,sin(x))
title('sine graph')
xlabel('x')

ylabel('sin(x)')
grid
subplot(3,1,2),plot(x,cos(x))
title('cosine graph')
xlabel('x')
ylabel('cos(x)')
grid
subplot(3,1,3),plot(x,exp(2*x))
title('exponential graph')
xlabel('x')
ylabel('exp(2*x)')
grid on

You might also like