Academic Year 2023
Physics entry test – session 3
1. What is the output of this code
A = 3:30;
B = -21:-8;
A = reshape (A, [4,7]);
B = reshape (B, [7,2]);
C = A*B;
disp(size (C) *3);| A | B | C | D | E | F | G | H |
|---------|-------|--------|-------|-------|-------|--------|--------|
| (12,21) | (9,9) | (12,6) | (3,3) | (4,8) | (8,3) | (16,8) | (28,8) |2. What is the output of this code?
x = linspace (25,11,3);
y = 4: (exp(2) -1);
z = cross (x, y);
disp (max(z));| A | B | C | D | E | F | G | H |
|----|----|---|----|----|-----|---|----|
| -1 | 54 | 3 | 53 | 46 | 119 | 0 | 16 |3. What is the output of this code?
M(1,:) = [2,0,2];
M(2,:) = [4,-0.5,0];
M(3,:) = [4,0,0];
N = transpose (M) ;
I = inv(N) ;
E = max(eig (I));
disp(E) ;| A | B | C | D | E | F | G | H |
|---|------|----|-----|---|---|-----|----|
| 2 | 0.25 | -1 | 0.5 | 1 | 4 | 4.5 | -2 |4. What is the output of this code?
str = '3';
for ik = -1:8
j = ik + 1;
if check value(j)
str = strcat(str,num2str(j));
end
end
disp(str)
function out = check value (val)
val = val + 7;
if mod (val, 5)>2
out=1;
else
out=0;
end
end| A | B | C | D | E | F | G | H |
|-----|------|----|------|-------|-------|-------|------|
| 312 | 2784 | 27 | 3712 | 31267 | 32768 | 32165 | 5673 |5. What is the output of this code?
A = 1:2:17;
A = reshape (A, [3, 3]);
B(:,1) = linspace (3,1,3);
C = A*B;
disp([1 -2 1]*C);| A | B | C | D | E | F | G | H |
|----|-----|----|----|---|-----|----|---|
| 49 | -27 | 34 | -2 | 5 | -71 | 21 | 0 |6. What is the output of this code?
x = [1:0.005:10];
y = sin(x) .*(cos(10*x) + 1);
plot (x, y)
Last updated