single row matrix vector subtraction

2 visualizaciones (últimos 30 días)
PK
PK el 23 de Oct. de 2012
Comentada: QuanCCC el 17 de En. de 2019
i require the following calculation but my trial failed hope some one can help in this i have two matrices best=1x100 matrix and WIN=10x100 matrix and my problem is to subtract every row of WIN matrix with singe row matrix best i have used for loop but finally its giving one 1x100 ie., only 10th row but i require all the 10 rows ie 10x100 matrix after subtraction in a single variable

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 23 de Oct. de 2012
best=randi(20,1,100);
WIN=randi(40,10,100);
out = bsxfun(@minus,WIN,best);
  3 comentarios
Andrei Bobrov
Andrei Bobrov el 23 de Oct. de 2012
please read about function bsxfun
QuanCCC
QuanCCC el 17 de En. de 2019
bsxfun is very useful. Thank you!

Iniciar sesión para comentar.

Más respuestas (1)

Sachin Ganjare
Sachin Ganjare el 23 de Oct. de 2012

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by