Ma'lab Pasqwo
Ma'lab Pasqwo
Ma'lab Pasqwo
Index Number:
________________________KATALAN______________________
(Write Your Index Number On Every Other Page)
CALCULATORS ARE PERMITTED IN THIS EXAMINATION.
1. Which control structure is suitable for repeating a process for a finite number of times?
___rand____________________________________
2. Write a Matlab command that can create a vector, x containing the sequence of elements
1 , 5 , 4 , 11 , , 31 . ___x =[1/3:0.5:31/3]
3 6 3 6 3
3.
____________________
Use the following script which executed in Matlab to answer question 4 and 5
mysum = 0;
for i = 1:5
if i > 2;
mysum = mysum + i;
end
end
disp([‘mysum = ’, num2str(mysum)])
4. What best describes the output at Matlab’s command line?
__mysum=12_____________________________________
6. If the command z=(x>=3) is executed in the command line what will be the value of z?
7.
________0 1 1____________________________________
1
9. If 100445.987 is entered in Matlab command window and 100445.99 is returned, what type
of format is being used? ___format bank_______________________________
10. The format long displays how many significant digits? 15______________
2
Index Number : _____________________________________
13. What will be the output of this script in the command line? 1 9 4 1___
14. If the vector x is replace with x = [–2 –2 –3 0], what will the output be?
4490
15. A(1,:) 16 3 2
16. A(:,1) 16 5 9
20. What simple command would you issue at the command window to display the submatrix
3 2
10 11 of A, above? _____A([4 7;5 8])
21. MatLab recognizes only the first __63__________characters of a variable name in Release 6.5
or newer.
22. All variables used in the current MATLAB session are saved in the
_________workspace_____________.
23. To enter a statement that is too long to be typed in one line, use ___ellipsis_...__________
followed by the Enter or Return
26. Which MATLAB command together with an existing or valid function name gives us the
location of that every function? ___what__________________________________
3
1 2
29. If A , then the command det(A) in MATLAB will produce the result __-1_______
2 3
32. The MATLAB command for viewing/listing variables of the current sessions: who_______
33. To enter a statement that is too long in MATLAB, one uses __ellipses...
34. How many types of m-files has MATLAB gotten: __2- matlab script and matlab
functions________________
35. Matrices are entered by rows with _space/comma separating the entries and _semi-colon ;
separating the rows.
37. The entry in the ith row and jth column of a matrix A is given in MATLAB by _(ith, jth)__
38. To have several plots in one figure window, what MATLAB commands would you use?
_subplots
39. What command will produce a 2 x 4 matrix with zero entries? ___zeros(2,4)_____________
40. What command will produce a 2 x 4 matrix with one entries? ____ones(2,4)_____________
43. To suppress output in MATLAB, which of the following notations is used? ____;_semi
colon__________
44. The hold on command allows for addition of plots to an existing graph.
Given a=[ 1 2 2 4], b=[2 2.5 2 4], c=[1 1 2 2]. What is the result when the
following expressions are entered in MATLAB? Questions 46—55
45. a .* b = ___2 5 4 16
4
Index Number : _____6170111________________________________
52. pow2(c)= __ 2 2 4 4
54. a & c = _1 1 1 1
Given a=1.75 and b=2.35, what be would the output of the following? Questions 82—83
81. floor(a*b)= _____4________________
83. How would the mathematical expression 0<r<1 be represented in MATLAB. ___r>0 & r<1___
86. For the function defined in [86], what is the result of the following MATLAB commands?
>>x=[1:1:3];
>> f(x)_______error____________
90. To clear the command window in MATLAB, what command is used? _____clc______
91. Suppose A=[9 4 4 4;2 8 0 6;6 7 8 7]. What would matrix B look like if
>> B=A( : , 1:2)___[9 4;2 8;68]___________________
92. If x and y are vectors of equal length, then what does the MATLAB command
plot(x,y) do? _____a plot of the graph of y___________________________
Start
Input x, y
i = 1, sum = 0
No
i<y Print; sum, x, y
Yes
sum = sum + ( –x)^(i) + y
i=i+2 y = y +1 Stop
x=x+y
100. What will be the value of sum at the end of the program?
Ans: _______2_____________________
7
Use the following script to answer question 104.
x = input('Enter the value of x: ');
y = input('Enter the value of y: ');
temp = x;
x = y;
temp = x;
for i = 1:2:x
temp = temp + y * i;
y = 2 * y;
end
disp(['temp = ',num2str(temp)])
disp(['y = ',num2str(y)])
103. When 5 and 6 are inputted for x and y respectively, describe the output.
Ans: ______temp=168 y=48___________________
Write the following Mathematical expressions in MATLAB. Questions 105—110.
104. A P(1 r )n
A=P*(1+r)^(n)____________________________________________________________
b b2 4ac
105. x
2a
__________________ x=(-b+sqrt(b^(2)-4*a*c)/(2*a)______________________________
106. tan 1 90 sin 1 45
_____atan(pi/2)+asin(pi/4)___________________________________________________
1
107. 3 2w3 y 4
3
_____(sqrt(2*w^(3)+(y^4)/3))^(1/3)________________________________________________
________
1
108. =1/(exp(x)-exp(-x)) ______ ____
e e x
x
_________________________________________________________
log 2 256
109. =log2(256)/log10(2)
ln 2
_________________________________________________________________
E. Agyeman
MATLAB 4 YOU
ROLL CALL
SULEYMAN ABDUL-JABBAR
0542490681
8
Index Number : _____6170111________________________________