Home » MATLAB » MATLAB Basics
Que.What would be the output of the following code (in editor window)?A = [0 1; 1 0] ; B=2 ; C = A + B
a. 1 24 5 b. 2 33 2 c. 3 23 2 d. 3 22 3
Que.What would be the output of the following code (in editor window)?A = [1 0 2] ; b = [3 0 7] ; c=a.*b;
a. [2 0 21] b. [3 0 14] c. [14 0 3] d. [7 0 3]
Que.What would be the output of the following code (in editor window)?a=1:5 ; c=a.^2
a. [1 25] b. [1 2 3 4 5] c. [25 16 9 4 1] d. [1 4 9 16 25]
Que.What would be the output of the following code (in editor window)?A = [1 1 0 0]
B = [1 ;2 ;3 ;4]
C=A*B
a. 0 b. [1 0 0 0] c. 3 d. [1 2 0 0]
Que.What would be the output of the following code (in editor window)?A = [1 2; 3 4]
C = A^2
a. [7 10; 15 22] b. [1 4; 9 16] c. [16 9; 4 1] d. [22 15; 10 7]
Que.What would be the output of the following code (in editor window)?A=1:5;
B=cumprod(A)
a. b=[1 2 6 24 120] b. b=[1 2 3 4 5] c. b=[5 4 3 2 1] d. b=[120 24 6 2 1]
Que.Create an array of logical values.A = [true false true; true true false]A = 1 0 11 1 0B = cumprod(A,2)Find the cumulative product of the rows of A. a. B = 1 0 00 1 0 b. B = 1 0 01 1 0 c. B = 1 0 01 1 1 d. B = 1 1 01 1 0
Que.Find the cumulative sum of the columns of A. A =1 4 7
2 5 8
3 6 9
B = cumsum(A)
a. B = 1 4 73 8 156 15 24 b. B = 1 4 74 9 154 15 24 c. B = 1 4 73 9 156 15 29 d. B = 1 4 73 9 156 15 24
Que.Create a 4-by-2-by-3 array of ones and compute the sum along the third dimension.A = ones(4,2,3);
S = sum(A,3)
a. S = 3 33 33 33 3 b. S = 3 43 43 43 4 c. S = 2 32 32 32 3 d. S = 7 35 36 33 3
Que.Round each value in a duration array to the nearest number of seconds greater than or equal to that value.t = hours(8) + minutes(29:31) + seconds(1.23);
t.Format = 'hh:mm:ss.SS'
t = 08:29:01.23 08:30:01.23 08:31:01.23
Y1 = ceil(t)
Y2 = ceil(t,'hours')
a. Y1 = 08:29:02.00 08:30:02.00 08:31:02.00Y2 = 09:00:00.00 09:00:00.00 09:00:00.00 b. Y1 = 08:29:02.00 08:30:02.00 08:31:02.00Y2 = 08:29:01.23 08:30:01.23 08:31:01.23 c. Y1 = 08:29:01.23 08:30:01.23 08:31:01.23Y2 = 08:29:01.23 08:30:01.23 08:31:01.23 d. Y1 = 008:29:01.23 08:30:01.23 08:31:01.23Y2 = 09:00:00.00 09:00:00.00 09:00:00.00
Show Answer Y1 = 08:29:02.00 08:30:02.00 08:31:02.00Y2 = 09:00:00.00 09:00:00.00 09:00:00.00