MATLAB help, code for Frobenius norm

  • Thread starter tweety1234
  • Start date
  • #1
112
0
Hello,

I am trying to write a mtlab code to compute Frobenius norm of an mxn matrix A.

defined by
[tex] ||A||_{F} = \sqrt{ \sum_{i=1}^m \sum_{j=1}^n a^{2}_{i,j}} [/tex]

I have so far written this code, but it does not work, if anyone can help /guide me to the right path, would be greatly appreciated.

function w = frobeniusnorm(a,m,n)
for i =1:m
sm = 0
for j =1:n
sm = sm+A(i,j)*a^2(i,j);
end
 

Answers and Replies

  • #2
marcusl
Science Advisor
Gold Member
2,790
449
You need to initialize the sum before you start your loops, so put the 3rd line before the 2nd. Don't forget to take the square root at the end.
 

Related Threads on MATLAB help, code for Frobenius norm

  • Last Post
Replies
0
Views
8K
  • Last Post
Replies
2
Views
9K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
14
Views
4K
  • Last Post
Replies
1
Views
8K
Replies
1
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
0
Views
4K
  • Last Post
Replies
0
Views
5K
  • Last Post
Replies
3
Views
2K
Top