Midterm Model Exam
Midterm Model Exam
Name:
Section: ID No:
Question NO.
Total Points Points
Q1 5
Q2 2
Q3 2
Q4 2
Q5 2
Q6 3
Q7 4
Total 20
a) linspace(9,9,5) b) linspace(0,9,5)
c) linspace(0,5,9) d) linspace(5,9,9)
a) ascend(A) b) sort(A)
c) order(A) d) inv(A)
>> [d,n]=min(A)
a) d=-18,n=9 b) d=-18,n=5
c) d=5,n=-18 d) d=9,n=-18
4) If matrix A= [3 6;-5 8], find the determinant of square matrix A,
using matlab built in function.
a) det(A) b) sort(A)
c) mean(A) d) inv(A)
>> x = -9/4;
>> floor(x)
a) 3 b)-3 c)-2.25 d) 2.25
Q2) Solve the following system of three linear equations:
7x – 2y + 5z = –17.5
– 4.5x+2y+ 3z = 5.5
7x – 9y- z = 10
Matlab Command:
Q3) Using the zeros, ones, and eye commands, create the following array by
0 1 0
typing one command: [0 0 1]
1 1 1
Q4) For the function y = x2- e0·5x + x , calculate the value of y for the following
Matlab Command:
Q5) Use the fplot command to plot the function: f(x) = (sin2x + cos25x) e -0.2x in
the domain -6 ≤ x ≤ 6. Add a legend and label the axes.
Matlab Command:
-x -x -x
Q6) Plot the function f(x) = x2e and its derivative f’(x) = 2x e - x2e for
0 ≤ x ≤ 10 in one plot. Plot the function with a solid line, and the derivative with a
dashed line. Add a legend and label the axes.
Scripts:
Q7 (Answer any four of the following questions)
20 −6 1 7 6
Given matrix A= [ 6 9 10 2 9] , choose the MATLAB commands
5 14 6 2 0
10 −1 0 5 3
for the following questions
1) Select all elements in the first two rows and the third (3rd) and
fifth (5th) columns of A.
a) sum(A(:,3)) b) sum(A(3,:))
c) sum(A,3) d) sum(A(3,3))
a) A(2,:)={} b) A(:,2)={}
c) A(:,2)=[] d) A(2,:)=[]
a) reshape(A,2,10) b) reshape(A,10,2)
c) reshape(A(10,2)) d) reshape(A(2,10)
a) A(6,:)=B b) A(6,:)=B’
c) A(:,6)=B d) A(:,6)=B’