Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help optimizing matlab code

  1. Jun 10, 2010 #1
    Ok, so i wrote a small matlab program but it takes forever for matlab to calculate it. Since i'm not very knowledgeable in optimizing code i hoped somebody could help me here. The only thing i did was use preallocation of my variable 'conditionnr'. The H matrix i'm using is a pretty big one (433x270 double).

    Code (Text):

    k=1;
    conditionnr = zeros(1,size(H,1));
    while(k<size(H,1)+1)
        for i=1:size(H,1)
            Htemp = H;
            H(i,:)=[];
            conditionnr(i) = max(svd(H))/min(svd(H));
            H=Htemp;
        end
        [m,j] = min(conditionnr);
        H(j,:)=[];
        if size(H,1)==size(H,2)
            k=size(H,1)+1;
        end
    end
     
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted