How many errors will MATLAB show if the following code entered? [code]A=[1;2;3]; B=[1 2]; C

Phương Quyên

New member
How many errors will MATLAB show if the following code entered?
Code:
A=[1;2;3]; B=[1 2]; C=A.*B;D=C*A;
A. 2
B. 1
C. No error
D. 4
 
Answer: b
Explanation: There are two errors here. Firstly, vector dimensions should be the same for A and B to compute the C matrix. Secondly, vector multiplication is done by the symbol ‘.*’. So, D=C*A will give an error but MATLAB as soon as it encounters the first error, it will stop compiling the code and return the first error invoked. Hence the number of errors MATLAB will show is 1.
 

Tìm kiếm

Back
Top