matrix columnwise subtraction
1 回表示 (過去 30 日間)
古いコメントを表示
I have the following matrix:
[ 1 2 3
1 3 4
4 5 6]
I need:
[ 0 -1 -2
0 -2 -3
0 -1 -2]
How can I do it?
0 件のコメント
採用された回答
Image Analyst
2011 年 11 月 25 日
Try bsxfun:
% Generate sample data.
m = rand(3,5)
% Extract out the first column
m1 = m(:,1)
% Subtract first column from all the columns.
mMinusM1 = bsxfun(@minus,m,m1)
2 件のコメント
Titus Edelhofer
2011 年 11 月 25 日
Small typo, to reproduce the example you need to subtract m from m1: m1MinusM = bsxfun(@minus, m1, m).
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!