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

Sơn Lê

Member
What is the output of the following code?
Code:
A=[1 2 3]; A^2;
A. [1 4 9]
B. A= 1 4 9
C. A= [1, 4, 9]
D. Inputs must be a scalar or a square matrix
 
Answer: d
Explanation: Multiplying a column or row vector with a scalar or another vector requires the code to be “A.^2” in place of “A^2”. If this line is replaced, the output will be: A=1 4 9
Output: Inputs must be a scalar and a square matrix.
To compute element wise POWER, use POWER (.^) instead.
 

Tìm kiếm

Back
Top