Reputation: 524
let x = [1 2 3;4 5 6]
then why norm(x,2)
is different from norm(x(:),2)
norm(x,2) = 9.5080
and norm(x(:),2)=9.5394
.
I have run this program in Matlab R2012a.
Upvotes: 5
Views: 138
Reputation: 439
As defined in Matlab help for norm, the returned value is "The largest singular value" for matrices, and sum(abs(A).^2)^(1/2)
for vectors.
Additional reading: wikipedia - matrix norm
Upvotes: 5
Reputation: 78364
x(:)
is a vector, see what Matlab returns if you simply type that at the command-line. x
is a matrix. The 2-norm of a matrix and the 2-norm of a vector are calculated in different ways, in general the 2-norm of the vector of the elements of an array will not be the same as the 2-norm of the array. For details see good old Golub and Van Loan.
Why are the 2-norms of matrices and arrays different ? That's maths and therefore off-topic here on SO so I daren't answer.
Upvotes: 3