Multiplying Matrices, but with elements added together
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kevin Shen
el 10 de Oct. de 2020
Comentada: Star Strider
el 10 de Oct. de 2020
Hello!
I have vector matrix A (3x1) and row matrix B (1x3). When multipying A*B, instead of having each element in the new 3x3 matrix be the elements multiplied together, is there a way to still make the 3x3 matrix but instead of each element of one matrix being multiplied by the elements of the other matrix, they would be added together.
If I don't make sence please tell me, I am new to MATLAB. Image of desired outcome below.
Thanks!
Kevin
Respuesta aceptada
Star Strider
el 10 de Oct. de 2020
Yes, there is!
Try this:
A = [2; 3; 4];
B = [1 3 5];
C = bsxfun(@times, A, B) % Before R2016b
C = A * B % R2016b And Later
producing (for both):
C =
2 6 10
3 9 15
4 12 20
.
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
