If I let A, B, and C be 2x2 matrices, is it possible for me to assign a label to each matrix element in matrix C where C = A*B?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Craig Egan Allistair Tan
am 4 Jun. 2022
Kommentiert: Sam Chak
am 4 Jun. 2022
Let A, B, and C be separate 2x2 matrices. In this case, we let matrix C = A*B.
4 Kommentare
Sam Chak
am 4 Jun. 2022
Can you give an example? Like...
A = [1 2; 3 4]
A =
1 2
3 4
B = [5 6; 7 8]
B =
5 6
7 8
C = A*B
C =
19 22
43 50
det(C)
ans = 4.0000
Akzeptierte Antwort
Matt J
am 4 Jun. 2022
Bearbeitet: Matt J
am 4 Jun. 2022
I'm talking about assigning a variable to each matrix element
One way,
A=rand(2);
B=rand(2);
C=A*B,
tmp=num2cell(C);
[c1,c2,c3,c4]=deal(tmp{:})
1 Kommentar
Walter Roberson
am 4 Jun. 2022
Note that changing the c* variables will not change the matrix. The above code does not define the c* variables as being "references" to the array elements, only as copies of the array elements. There is no way to create references to individual elements of a numeric array.
Weitere Antworten (1)
Matt J
am 4 Jun. 2022
Bearbeitet: Matt J
am 4 Jun. 2022
The attached class might be what you are looking for, if all you want to do are the operations C=A*B. To understand what it's doing, you need to get familiar with handle classes.
A=myclass(rand(2)), B=myclass(rand(2)),
C=A*B
c12=C(1,2)
C(1,2)=3
c12
1 Kommentar
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!