Lab Report 1
Lab Report 1
MECHANICAL ENGINEERING
EE-232
BE34-12-807
NS ZARRAR HAIDER
BE34-12-860
SUBMITTED TO
Lab. Engr. Salman Qadir
a=[1 2 3]
transpose(a)
a.'
a'
%row vector
%finding transpse of a
%conjugate of a
%for matrix with real elements conjugate = transpose
%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)
%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=a(2,:)
b=a(:,2)
b=a(2:3, :)
b=a(:, 1:2)
%b
%b
%b
%b
z=eye(8)
b=z(5:7, 1:3)
a=1:20
a=1:0.01:10
equals
equals
equals
equals
2nd
2nd
2nd
1st
row of a
column of a
and 3rd rows of a
and 2nd columns of a
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