single row matrix vector subtraction

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

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 10 月 23 日

0 投票

best=randi(20,1,100);
WIN=randi(40,10,100);
out = bsxfun(@minus,WIN,best);

3 件のコメント

PK
PK 2012 年 10 月 23 日
hello u have given as bsxfun(@minus,WIN,best); can u pls tell what these type of functions are called as
Andrei Bobrov
Andrei Bobrov 2012 年 10 月 23 日
please read about function bsxfun
QuanCCC
QuanCCC 2019 年 1 月 17 日
bsxfun is very useful. Thank you!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

PK
2012 年 10 月 23 日

コメント済み:

2019 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by