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

Signals and Systems: Lab Report # 1

This lab report summarizes Lab 1 on basic MATLAB commands. The lab report was submitted by NS Faizan Hussain and NS Zarrar Haider to Lab Engineer Salman Qadir. The lab covers basic MATLAB commands like matrices, vectors, matrix operations, plotting, trigonometric functions, saving and loading variables, and MATLAB documentation. Code examples are provided to demonstrate various MATLAB commands.

Uploaded by

Rashid Altaf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Signals and Systems: Lab Report # 1

This lab report summarizes Lab 1 on basic MATLAB commands. The lab report was submitted by NS Faizan Hussain and NS Zarrar Haider to Lab Engineer Salman Qadir. The lab covers basic MATLAB commands like matrices, vectors, matrix operations, plotting, trigonometric functions, saving and loading variables, and MATLAB documentation. Code examples are provided to demonstrate various MATLAB commands.

Uploaded by

Rashid Altaf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EE-232

SIGNALS AND SYSTEMS


LAB REPORT # 1

SUBMITTED BY
NS FAIZAN HUSSAIN

BE34-12-807

NS ZARRAR HAIDER

BE34-12-860

SUBMITTED TO
Lab. Engr. Salman Qadir

LAB 1: BASIC MATLAB COMMANDS


CODE
clear all
close all
clc

%clear all memory


%close all open windows like plots
%clear command window

a=[1 2 3]
transpose(a)
a.'
a'

%row vector
%finding transpse of a
%conjugate of a
%for matrix with real elements conjugate = transpose

f=[1i 2+1i 3-2i]


f'
%conjugate
transpose(f)
%transpose
b=[1;2;3]
c=a*b

%column vector
%matrix multiplication
%valid only if no of col of a = no of rows of b

A=[1 2 3]
save('file.mat','A') %saves A in file
clear A
%clears A from memory, we cannot use it anymore
load file.mat
%after loading file we can use A again
d=zeros(4)
%a 4x4 matrix with all entries 0's
e=ones(3,2)
%a 3x2 matrxi with all entries 1's
i=eye(3)
%a 3x3 identity matrix
a=[2 -1 0;1 3 -1;-3 0 1]
det(a)
%finding determinant
b=inv(a)
%finding inverse
det(a)*inv(a)
%adjoint of a
1/0
%gives infinity
c=[1 3 3;1 4 3; 1 3 4]
inv(c)
%inverse
c/a
% c * inv(a) -post multiply
a\c
% inv(a) * c -pre multiply
a^2
a.^2
a.*c
b=a(3,2)
b=a(2,:)
b=a(:,2)

%a*a
%squares each element of a
%multiples corresponding element of a and c
%b gets value in 3rd row, 2nd col of a
%b equals 2nd row of a
%b equals 2nd column of a

b=a(2:3, :)
b=a(:, 1:2)

%b equals 2nd and 3rd rows of a


%b equals 1st and 2nd columns of a

z=eye(8)
b=z(5:7, 1:3)

%b equals portion of z (row 5 to 7)(col 1 to 3)

a=1:20
a=1:0.01:10

%a is row vector with 1 as 1st element


%20 as last element, 1 as spacing
%a is row vector with 1 as 1st element
%20 as last element, 0.01 as spacing
%plots entries of a against indexes

plot(a)
xlabel('index')
ylabel('values of a')

b=cos(a)
%takes cosine of every element of a
b=tan(a)
% apllies tan on every element of a
b=sin(a)
% applies sine on every element of a
plot(b)
%plots entries of b against indexes
xlabel('index') %label of x-axis of plot
ylabel('values of b')%label of y-axis of plot
t=0:0.01:2
v=sin(2*pi*2*t) %v=sin(wt)=sin(2*pi*f*t), freq=1
plot(t,v)
%plots values of v against corresponding value of t
xlabel('Time')
ylabel('Voltage')
title('Voltage vs Time') %title of plot
u=linspace(0,1,6)
%row vector 0 to 1 with 6 equally spaced numbers
v=asin(u)
%applies inverse sine
v=acos(u)
v=atan(u)
v=acot(u)
v=acsc(u)
v=asec(u)
doc
%for matlab help

PLOTS

You might also like