Unable to get correct 2θ value from tan2θ = (2*a12)/(a11-a22) by writing as p= A(1,1) - A(2,2) q= 2 * A(1,2) theta = atan (p/q).Please help
1 view (last 30 days)
Show older comments
Unable to get correct 2θ value from tan2θ = (2*a12)/(a11-a22) by writing as
p= A(1,1) - A(2,2)
q= 2 * A(1,2)
theta = atan (p/q) for a (2 x 2) matrix.My code and output are
INPUT >>>>>
% Write down Matrix elements in [A(1,1) A(1,2);A(2,1) A(2,2)] format
Matrix = 'Write down Matrix elements.'
A = input(Matrix)
if ne(A(1,2),A(2,1))
disp('This is a asymmetric matrix')
else
disp('1.This is a symmetric matrix')
% Write down Matrix elements in [A(1,1),A(1,2);A(2,1),A(2,2)] format
p= A(1,1) - A(2,2)
q= 2 * A(1,2)
theta = atan (p/q)
end
OUTPUT >>>>>
Matrix =
'Write down Matrix elements.'
Write down Matrix elements.
[1 2;2 4]
A =
1 2
2 4
1.This is a symmetric matrix
p = -3
q = 4
theta = -0.6435
while correct value from calculator is -0.9272 rad.
Please help me.
0 Comments
Accepted Answer
Geoff Hayes
on 22 Apr 2019
Amar - I think that you should have q/p instead so that
theta = atan (q / p)
and theta will be -0.9272. Not sure if you still need to divide that result by two since you really have
2*theta = atan(q / p)
2 Comments
Geoff Hayes
on 22 Apr 2019
Amar - I think that you are missing some brackets around the denominator
theta = (atan (2 * A(1,2)/(A(1,1) - A(2,2)))) / 2.0;
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!