What is the output of the following code? [code]A=[1 1; 1 1]; A^2[/code]

What is the output of the following code?
Code:
A=[1 1; 1 1]; A^2
A.
A = 2 2
2 2
B.
A = 1 1
1 1
C. Error using ^ To compute element wise POWER, use POWER (.^) instead
D. No output
 
Answer: a
Explanation: ‘A^2’ implies we are multiplying A with A, A being a square matrix. So the answer follows. If the line of code was ‘A.^2’, the answer would be a square matrix, such that a$_{ij}$=2 of order 2*2.
Output: Cursor shifts to the next line, waiting for a new line of code.
 

Tìm kiếm

Back
Top