MATLAB SCRIPT HELL. I mean.. help?

edited March 2010 in Science & Tech
A = input ('Please enter a 3x3 real matrix')

transpose = A'

if transpose = A
Symmetric;
elseif transpose = -A
AntiSymmetric;
else Neither;
end

I am writing a script to determine if a matrix is symmetric, antisymmetric or neither. It will not work, saying the equalities I've put in the if section are invalid or something! Can anybody see something wrong?

Comments

  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited March 2010
    MATLAB, like most languages, uses '=' for the assignment operator and '==' for the relational equivalence operator. You used the assignment operator when you wrote "transpose = A'", assigning the transpose of A to the variable transpose. However, to test equivalence you should use a relational operator. MathWorks wrote up a nice help file in the MATLAB help (also available online: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/relationaloperators.html). You'll immediately note that the result of a relational operation between a pair of matrices is another matrix, so the relation you've suggested in your code may not be correct.

    By the way, if you want something to show up on the screen (e.g. Symmetric, AntiSymmetric, Neither) you should use disp(). In a command window, run 'doc disp' for usage and context.

    -drasnor :fold:
Sign In or Register to comment.