What is the output of the following code? [code]A=[1 2]; B=[1 4]; c=A*B;[/code]

Mỹ Duyên

New member
What is the output of the following code?
Code:
A=[1 2]; B=[1 4]; c=A*B;
A. c= [1 8]
B.
c = 1
8
C. Inner Matrix dimensions must agree
D. No output since we have closed the line of code with a semicolon
 
Answer:c
Explanation: Multiplication of two row vectors is possible if we use the ‘.*’ operator. If B was a 1*2 column vector, the multiplication would have been possible resulting in a multiplication of vectors and generating c=9 as output.
 

Tìm kiếm

Back
Top