Exponentiation of Matrix Columns by different Powers
Mostrar comentarios más antiguos
Given an MxN matrix A and a 1xN vector b, is there a concise way to raise each column of A to a corresponding power of the vector b? For example, if N = 4, the resulting matrix C would be computed as:
C = [A(:,1)^b(1) A(:,2)^b(2) A(:,3)^b(3) A(:,4)^b(4)];
However, when N becomes large, explicitly writing this formula is not feasible. Is there a way to write this without the use of a loop? Thank you for any feedback.
1 comentario
John
el 6 de Jul. de 2015
Respuesta aceptada
Más respuestas (1)
James Tursa
el 6 de Jul. de 2015
C = bsxfun(@power,A,b);
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!