Matrix Equality Check Failed Using == and isequal
Show older comments
Hello guys,
I am confused about how MATLAB handles matrix equailty check. Consider the following example,
a = [262 -200; -200 200];
a_inv = inv(a);
% since it is a 2 by 2 matrix, we can perform inv operation like this
b = (1/(262 * 200 - 200*200)) * [200 200; 200 262];
a_inv == b
% 2×2 logical array
%
% 0 0
% 0 0
isequal(a_inv, b)
% ans =
%
% logical
%
% 0
But when I print these matrix, it gives me exact same result
format long
a_inv
a_inv =
0.016129032258065 0.016129032258065
0.016129032258065 0.021129032258065
b
b =
0.016129032258065 0.016129032258065
0.016129032258065 0.021129032258065
Not sure which step did I do wrong? ang suggestion to compare matrix properly?
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!