Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Please confirm or correct my evaluation of this code

Please confirm or correct my evaluation of this code

Please confirm or correct my evaluation of this code



    [ignore,maxind] = max(abs(U),[],1);
    negloc = (U(maxind + (0:N_f:(N_f-1)*N_f)) < 0);
    U(:,negloc) = -U(:,negloc);

(N_f is the number of columns in the matrix (actually the number of rows, but it is a square matrix, so same-same))

I am assuming that these two line multiply all the elements of the columns where the maximum absolute value comes from a negative number by -1, without modifying or eliminating any other columns.  Is this correct?


    [U,D] = eig((correlation_matrix+correlation_matrix')/2);
    D = diag(D);

Okay, my evaluation of the last line above
Square the elements of Matrix U, multiply that D, and then "squareroot" all the elements, then apply the diag method.
My question is, is D a vector or a "square" matrix at that point.  I am assuming a Vector as norma is used as a square matrix later in the program, and D should be, after "eig" a "square" matrix, and so a vector after the call to diag.  I find it very bad form to use "D" as the variable for both a vector and a matrix, if that's the case though.

I cannot run this code, as I do not have a matlab environment.  I am porting this code to something else, and I just want to make sure that my "assumptions" are correct, or get them corrected, if they are not.

I am also posting this question [url=]here[/url] and [url=]here[/url].

RE: Please confirm or correct my evaluation of this code

Nevermind, got help from somewhere else. Thanks anyway.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close