What is the output of the following code? [code] >> { 1 2} ans = 1*2 cell array [1] [2] >> ans+{3 4}[/code]

What is the output of the following code?
Code:
 >> { 1 2}
 ans = 
   1*2 cell array
     [1]   [2]
>> ans+{3 4}
A. { 1 2 3 4}
B.
{ 1 2
3 4}
C. { 4 6}
D. Error
 
Answer: d
Explanation: Cellular arrays cannot be added in MATLAB. Hence the above code will result in an error. if the arrays were within [], the would’ve been simple 1d vectors which could be easily added.
 

Tìm kiếm

Back
Top