1. Assignment # 3
Fall 2015
Course title: STRUCTURED COMPUTER PROGRAMMING Course #: EE201
Sections: All
Name: Student #:
Q1) Use MATLAB to do the following:
i) Create a vector M with exactly 25 values evenly distributed between -3 and 5
_
ii) Add 0.23 to all the odd-indexed elements of the vector M and assign the result to N
_
iii) Create a vector V of only the even numbers between 32 and 75. (i.e.: 32 34 36 … 72 74)
_
iv) Find the total number of elements in vector V
_
v) Find the 7th element of the vector V
_ M=linspace(-3,5,25)
M(1:2:end)+0.23
V=32:2:74
length(v)
M(7)
1324593 khaled mohammed al-awlaqi
2. EE201 – Lab Assignment 3 Fall 2015
Page 2 of 3
Q2) Create a Matrix A with the following numbers: 퐴=[ 1068−37−22−4319−45632]
_____________________________________________________________________
i) Extract out the 3rd row of matrix A as a vector and assign this to a vector m using array addressing
퐴=[ 1068−37−22−4319−45632]
_____________________________________________________________________
ii) Transpose matrix A and store the result in matrix B
_____________________________________________________________________
iii) Replace the 3rd column of matrix A with 2nd row of matrix B using array addressing
_____________________________________________________________________
iv) Delete the 3rd column of matrix B
_____________________________________________________________________
v) Create a 2×3 matrix D consisting of all elements in the first two rows and the last three columns of matrix A using array addressing
[ 1068−36−2−3−4319−416−42]
_____________________________________________________________________
vi) Find the maximum values in each column of matrix A
_____________________________________________________________________
>> b=a' b = 10 8 3 9 , 6 -3 1 -4 ,7 2 5 3, 2 -4 6 2
A(3,:) 3 1 5 6
A'(3,:) b = 10 8 3 9, 6 -3 1 -4, 7 2 5 3, 2 -4 6 2
A(:,3)=A(2,:)
d=b(:,3)
D=a(1,2,2,4)
max(a)
3. EE201 – Lab Assignment 3 Fall 2015
Page 3 of 3
vii) Find the minimum values in each row of matrix A
_____________________________________________________________________
viii) Sort each row of matrix A in descending order and store the result in Y
_____________________________________________________________________
ix) Find the sum of the third column of matrix Y
_____________________________________________________________________
Q3) Let a = [3 2 6 8] and b = [4 1 3 5]. Find the following:
i) x = a × b
_____________________________________________________________________
ii) 푦= √푎+Σ푏푎
_____________________________________________________________________
iii) 푧=0,13⁄,25⁄,37⁄,…푢푝 푡표 715⁄
_____________________________________________________________________
iv) 푛= −1푖+1sin(2푖) 푖2−1 푤ℎ푒푟푒 푖 푖푠 푎 푣푒푐푡표푟 푓푟표푚 0° 푢푝푡표 90°
_____________________________________________________________________ >> min(a,[],2 ) ans = 3 -4 2
y=sort(a) y=3 -4 2 -4 8 -3 3 2 9 15 2 10 6 7 6
sum a(:,3)
a.*b
y=sqrt([3 2 6 8 ])+sum(b.^[3 2 6 8 ])
z=[0:7]/15
n=(-1.^([0:90]+1).*sin(2.*[0:90]))/(([0:90].^2)-1)