Academic Year 2022 Sample
Physics entry test – session 2
1. What is the output of this code
A = 1:8;
A = reshape (A, [2,4]);
V = ones (1,4);
R = A. *V;
disp (size (R) );| A | B | C | D | E | F | G | H |
|-------|-------|-------|-------|-------|-------|-------|-------|
| (1,8) | (2,8) | (2,4) | (4,1) | (4,8) | (8,1) | (8,4) | (4,2) |2. What is the output of this code?
x = linspace (3,1,3);
y = 1:pi;
z = cross(x,y);
disp (max(z));| A | B | C | D | E | F | G | H |
|---|---|---|---|---|-----|-----|---|
| 0 | 1 | 5 | 3 | 4 | 2.8 | 3.5 | 9 |3. What is the output of this code?
R(1,:) = [0,0,5];
R(2,:) = [0,4,0];
R(3,:) = [3,0,0];
Q = inv(R) ;
e = round (max (eig (Q)) , 2) ;
disp (e);| A | B | C | D | E | F | G | H |
|------|------|-------|-----|---|-----|------|---|
| 0.50 | 1.50 | 0.255 | 2.4 | 7 | 2.8 | 0.26 | 9 |4. What is the output of this code?
string = [];
for ik = 1:8
if check number(ik)
string = [string,num2str(ik)];
end
end
disp(string) ;
function flag = check number(number)
flag = 0;
number = number+1;
if mod (number, 3) ==0
flag=1;
end
end| A | B | C | D | E | F | G | H |
|-----|-----|------|---|----|---|---|----|
| 258 | 326 | 1357 | 3 | 36 | 6 | 1 | 16 |5. What is the output of this code?
A(1,:) = linspace(7,1,3);
A(2,:) = linspace(3,1,3);
A(3,:) = ones(1,3);
A(3,:) = A(2,:).*A(3,:);
B = 3:5;
C = reshape (B, [3,1]);
D = A*C;
disp((1:3) *D);| A | B | C | D | E | F | G | H |
|-----|-----|-----|-----|-----|-----|-----|----|
| 579 | 152 | 115 | 256 | 912 | 121 | 300 | 84 |6. What is the output of this code?
x = [0:0.005:5];
y = exp(-x) .*sin(10*x);
plot (x, y)
Last updated