How can i implement subtraction without using for-loop ?

3 ビュー (過去 30 日間)
Gn Gnk
Gn Gnk 2020 年 9 月 29 日
回答済み: Walter Roberson 2020 年 9 月 29 日
I have a vector J 1000x7 and a vector K 16x7
I want to take each row of J(one at a time) an subtract it from every row of K.
For example i want to take the first row of J and subtract it from each row of K and then take the 2nd row of J and do the same .
How can i implement this without using for-loop (because for loop is too slow for my programm).

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 9 月 29 日
JminusK = J - permute(K, [3 2 1]);
The size of JminusK will be 1000 x 7 x 16.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by