Related to Frobenius norm
Show older comments
Hello all, I am trying to find Frobenius norm of each column of 2 X 500 matrix in MATLAB but not getting it correctly.
Any help in this regard will be highly appreciated.
Answers (1)
From the documentation:
7 Comments
chaaru datta
on 22 Oct 2023
rng("default")
X = rand(3);
n = arrayfun(@(i)norm(X(:,i),"fro"),1:size(X,2))
n = vecnorm(X,2)
Dyuman Joshi
on 22 Oct 2023
Edited: Dyuman Joshi
on 22 Oct 2023
Since frobenius norm is defined as the square root of sum of the absolute squares of elements of an array, simply calculate it directly for each column -
y = rand(2,500);
sqrt(sum(abs(y).^2))
vecnorm(y,2)
Torsten
on 22 Oct 2023
"abs" seems to be superfluous.
Dyuman Joshi
on 22 Oct 2023
Edited: Dyuman Joshi
on 22 Oct 2023
It might be, but that's how Wikipedia and Wolfram Alpha define it.
Idk why though.
Dyuman Joshi
on 22 Oct 2023
That should be it.
For someone who has worked with real valued data only, it easily escapes my mind that people work with non-real valued data as well.
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!