Related to Frobenius norm

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.

Respuestas (1)

Torsten
Torsten el 22 de Oct. de 2023
Movida: Torsten el 22 de Oct. de 2023

0 votos

From the documentation:
n = norm(X,"fro") returns the Frobenius norm of matrix or array X.

7 comentarios

chaaru datta
chaaru datta el 22 de Oct. de 2023
Thank u sir for the answer...but I want to find the norm of each column of X.
Torsten
Torsten el 22 de Oct. de 2023
Editada: Torsten el 22 de Oct. de 2023
rng("default")
X = rand(3);
n = arrayfun(@(i)norm(X(:,i),"fro"),1:size(X,2))
n = 1×3
1.2249 1.1152 1.1373
n = vecnorm(X,2)
n = 1×3
1.2249 1.1152 1.1373
Dyuman Joshi
Dyuman Joshi el 22 de Oct. de 2023
Editada: Dyuman Joshi el 22 de Oct. de 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))
ans = 1×500
1.0265 0.8084 1.1542 0.5197 0.5827 1.0240 0.0890 1.3322 1.0956 0.4976 0.7836 0.1435 0.3630 0.7378 0.7803 1.0122 0.8657 0.8241 1.1077 0.2674 0.5666 0.6570 0.2569 0.8938 0.3199 1.0291 0.7741 0.4520 0.2461 1.0370
or use vecnorm -
vecnorm(y,2)
ans = 1×500
1.0265 0.8084 1.1542 0.5197 0.5827 1.0240 0.0890 1.3322 1.0956 0.4976 0.7836 0.1435 0.3630 0.7378 0.7803 1.0122 0.8657 0.8241 1.1077 0.2674 0.5666 0.6570 0.2569 0.8938 0.3199 1.0291 0.7741 0.4520 0.2461 1.0370
Torsten
Torsten el 22 de Oct. de 2023
"abs" seems to be superfluous.
Dyuman Joshi
Dyuman Joshi el 22 de Oct. de 2023
Editada: Dyuman Joshi el 22 de Oct. de 2023
It might be, but that's how Wikipedia and Wolfram Alpha define it.
Idk why though.
Torsten
Torsten el 22 de Oct. de 2023
Editada: Torsten el 22 de Oct. de 2023
For complex matrices most probably.
Dyuman Joshi
Dyuman Joshi el 22 de Oct. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 22 de Oct. de 2023

Editada:

el 22 de Oct. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by