Academic Year 2022 Actual

Physics entry test – session 2

1. What is the output of this code

A = 1:15;
A = reshape (A, [15,3]);
V = ones (1,3);
R = A. *V; 
disp (size (R) );
| A      | B     | C     | D     | E     | F     | G     | H      |
|--------|-------|-------|-------|-------|-------|-------|--------|
| (1,15) | (3,1) | (1,5) | (5,3) | (1,3) | (1,5) | (3,5) | (15,1) |

2. What is the output of this code?

x = linspace (7,1,3);
y = 1:(exp(1) + 1);
z = cross(x,y);
disp (max(z));
| A  | B | C | D | E | F | G   | H  |
|----|---|---|---|---|---|-----|----|
| 10 | 7 | 8 | 0 | 9 | 4 | 3.5 | 11 |

3. What is the output of this code?

R(1,:) = [0,0,2];
R(2,:) = [0,1,0];
R(3,:) = [4,0,0];
Q = inv(R) ;
e = max (eig (Q));
disp (e);
| A   | B    | C | D | E | F | G   | H   |
|-----|------|---|---|---|---|-----|-----|
| 1.5 | 2.50 | 1 | 6 | 8 | 2 | 4.5 | 3.5 |

4. What is the output of this code?

string = [];

for ik = 1:5
    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, 2) ==1
        flag=1;
    end
end
| A  | B  | C | D | E  | F | G   | H  |
|----|----|---|---|----|---|-----|----|
| 35 | 13 | 1 | 3 | 15 | 5 | 135 | 24 |

5. What is the output of this code?

A(1,:) = linspace(9,1,3); 
A(2,:) = linspace(6,1,3);
A(3,:) = ones(1,3)*2;

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   |
|-----|----|-----|-----|-----|-----|-----|-----|
| 276 | 49 | 734 | 127 | 234 | 348 | 456 | 511 |

6. What is the output of this code?

x = [0:0.005:5];
y = exp(-x/2) .*(2+sin(20*x));
plot (x, y)

Last updated