What is the output of the following code? [code]A=[1 2 3; 32 23 26; 0 0 0]; spones(A)[/code]

What is the output of the following code?
Code:
A=[1 2 3; 32 23 26; 0 0 0]; spones(A)
A. Returns a sparse matrix with the non-zeros replaced by normally distributed random numbers
B. Returns a sparse matrix with the zeros replaced by ones
C. Returns a sparse matrix with the non-zeros replaced by fractions
D. Returns a sparse matrix with the non-zeros replaced by random numbers
 
Answer: b
Explanation: The spones command returns a sparse matrix with ones replaced by zeros. Hence, Returns a sparse matrix with the zeros replaced by ones is correct while rest of the options are incorrect.
Output:
ans =
(1,1) 1
(2,1) 1
(1,2) 1
(2,2) 1
(1,3) 1
(2,3) 1
 

Tìm kiếm

Back
Top