how i subtract a vector( 1*n-dim ) from columns of a matrix (n*n-dim) without uses for , end and orders likes these?

 Respuesta aceptada

Stephen23
Stephen23 el 24 de Abr. de 2015
Editada: Stephen23 el 24 de Abr. de 2015
Use bsxfun for this:
>> A = [1, 3; 4, 2]
A =
1 3
4 2
>> B = [1, 2]
B =
1 2
>> bsxfun(@minus, A, B)
ans =
0 1
3 0
bsxfun expands any scalar dimensions to make the input variables the same size, then performs the specified operation. It is also much more efficient than using repmat.

Más respuestas (1)

Look at the function repmat() to tile the vector to perform the matrix subtraction.

Categorías

Etiquetas

Preguntada:

el 24 de Abr. de 2015

Comentada:

el 24 de Abr. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by