1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB help, code for Frobenius norm

  1. Feb 23, 2013 #1
    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
     
  2. jcsd
  3. Feb 27, 2013 #2

    marcusl

    User Avatar
    Science Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: MATLAB help, code for Frobenius norm
  1. Matlab code (Replies: 14)

Loading...