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?

Antworten (1)

Bruno Luong
Bruno Luong am 15 Feb. 2022
Bearbeitet: Bruno Luong am 15 Feb. 2022

0 Stimmen

"`C\D'` should be equal to finding the `x` s.t. `C=(D')*x`."
No. Rather
D' = C*x
Your code should be
while true
C = randi([0 ,1], [3,3]);
if rank(C) == 3
break
end
end
D = randi([0 ,1], [3,3]);
C
C = 3×3
0 1 1 1 1 1 1 0 1
D
D = 3×3
0 1 1 1 0 1 1 1 0
disp("D'-C*(C\D')")
D'-C*(C\D')
disp(D'-C*(C\D'))
0 0 0 0 0 0 0 0 0
Or
C = randi([0 ,1], [3,3]);
while true
D = randi([0 ,1], [3,3]);
if rank(D) == 3
break
end
end
C
C = 3×3
1 0 1 1 0 1 0 0 1
D
D = 3×3
0 1 1 1 1 1 1 0 1
disp("C-D'*(D'\C)")
C-D'*(D'\C)
disp(C-D'*(D'\C))
0 0 0 0 0 0 0 0 0

Produkte

Version

R2021b

Gefragt:

am 15 Feb. 2022

Bearbeitet:

am 15 Feb. 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by