Home > other >  Ordering of MATLAB operator
Ordering of MATLAB operator

Time:02-15

I'm trying to understand a MATLAB code for reserach but seem to be stuck in a basic question regarding the order of the transpose operator and ml divide operator. (please see the code below)

C = randi([0 ,1], [3,3])
D = randi([0 ,1], [3,3])

disp("C-(D')*(C\D')")
disp(C-(D')*(C\D'))

(you may need to run this multiple times until the inverse exists)

Because the transpose operator is computed before the \ operator, it seems taht C\D' should be equal to finding the x s.t. C=(D')*x... However, when I subsrtitute x as C\D' and display C-(D')*x, I don't get a zero... could anyone give me a reason why?

CodePudding user response:

C = [0,0,1;0,1,0;1,0,1];
D = [1,1,0;1,0,1;1,0,0];
%% rule
% "A \ B" equal to "inv(A) * B"
% "B / A" equal to "B * inv(A)"
%% mine
X = C / D'; % X = C * inv(D')
C - X * D'  % C - (C * inv(D')) * D' = C - C * (inv(D') * D') = 0
%% yours
Y = C \ D'; % Y = inv(C) * D'
C - D'* Y   % C - D' * (inv(C) * D') ≠ 0 
  • Related