Matlab order of operators
Ältere Kommentare anzeigen
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
am 15 Feb. 2022
Bearbeitet: Bruno Luong
am 15 Feb. 2022
"`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
D
disp("D'-C*(C\D')")
disp(D'-C*(C\D'))
Or
C = randi([0 ,1], [3,3]);
while true
D = randi([0 ,1], [3,3]);
if rank(D) == 3
break
end
end
C
D
disp("C-D'*(D'\C)")
disp(C-D'*(D'\C))
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!