matrix multiplication using bsxfun(@times,a,b)
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
summyia qamar
am 15 Dez. 2016
Beantwortet: John D'Errico
am 15 Dez. 2016
a=[1 0 0 1 0 1 1
0 1 1 1 0 0 1
1 0 0 1 1 0 0
1 0 0 0 1 0 1
1 1 0 0 0 1 0
0 1 0 0 0 1 1]
b=[0 1 0
0 1 0
1 0 0
0 0 1
0 0 1
0 0 1
0 0 1]
c=bsxfun(@times,a,b)
but it is giving error
Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.
how to multiply (6x7) matrix with (7x3) to get a matrix(6x3)
0 Kommentare
Akzeptierte Antwort
James Tursa
am 15 Dez. 2016
Bearbeitet: James Tursa
am 15 Dez. 2016
Not sure if this is the operation you really want from your description:
a = 6x7 matrix
b = 7x3 matrix
c = a * b; % 6x3 matrix
0 Kommentare
Weitere Antworten (2)
David Barry
am 15 Dez. 2016
The issue is because both a and b are vectors rather than matrices in the example you have shown there. Presumably what you want is something like:
a = reshape(a, 6, 7);
b = reshape(b, 7, 3);
c = a*b;
0 Kommentare
John D'Errico
am 15 Dez. 2016
Neither of those matrices is either 6x7 or 7x3, so your question is nonsense as written.
Perhaps your intention is that these VECTORS be reshaped into MATRICES of the given sizes. In that case, use reshape, then merely do a simple matrix multiply, using the * operator.
But you cannot use a tool like bsxfun to do something that only you know what you want it to do. Software simply does not work that way.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!