What does the function 'norm' do?
显示 更早的评论
Please tell me what does the 2(in bold) in the below expression mean?
residsumsq = norm(y-yhat, 2 )^2;
Also, Is the norm function referring to summation? I read the documentation but it is not clear.
采纳的回答
更多回答(2 个)
Bruno Pop-Stefanov
2014-2-21
8 个投票
The second input argument of the "norm" function specifies the order of the norm you would like to use. The default norm is the 2-norm, which is the Euclidean distance.
The p-norm is the p-th root of the sum of the terms elevated to the p-th power, i.e.:

3 个评论
Priya
2014-2-21
Walter Roberson
2014-2-21
No, it would be
SS_res = ∑(y-yhat)^2
There would normally be a sqrt() around the sum() but you then square the result of the norm, so that cancels out the sqrt()
Priya
2014-2-21
dpb
2014-2-21
0 个投票
It's the order of the norm requested, in this case the "2-norm" which is the same thing as the Euclidean norm...
类别
在 帮助中心 和 File Exchange 中查找有关 Direct Search 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!