Looping matrix differences for every iterations
1 回表示 (過去 30 日間)
古いコメントを表示
I have this scenario
A=[6;7;8] W=[3;9;1] d=|Ai-W| for each iterations take one value from A subtract with every value in W
1 iteration
d=
6-3
6-9
6-1
Like this for another iteration
0 件のコメント
採用された回答
Andrei Bobrov
2013 年 10 月 18 日
編集済み: Andrei Bobrov
2013 年 10 月 18 日
d = bsxfun(@minus,A(:)',W(:));
2 件のコメント
Jan
2013 年 10 月 18 日
@Anusha: Please read Andrei's suggestion again and think twice, why he prefers this method. It is a bda programming practice to insert an index in the name of a variable. His approach uses and index as index (!):
d(:, 1), d(:, 2), d(:, 3)
This is much more useful and efficient. You can e.g. expand the problem easily to millions of elements.
その他の回答 (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!