is possible Array + Array but element by element without using loop ?
古いコメントを表示
Dear colleagues
I want to know if there is a command that allow to add array with another array but without using a loop, I want something like this .* but adding.
here i write an example:
X= [1 2 3]; Y=[4 5 6];
Z= X.+Y Z = [(1+4) (1+5) (1+6) (2+4) (2+5) (2+6) (3+4) (3+5) (3+6)]
Z = [5 6 7 6 7 8 7 8 9]
thank you for your help
3 件のコメント
Ashmil Mohammed
2015 年 7 月 10 日
I dont know if there is a function , But does your situation restrict you from using loops?
Jorge Peñaloza Giraldo
2015 年 7 月 10 日
Star Strider
2015 年 7 月 10 日
My code is as fast as MATLAB can be to do the calculations you want. Large vectors will take longer with any code, but bsxfun is the fastest function for what you want to do.
If you want to do comparisons on the run times between various ways to do the calculations, use the timeit function.
採用された回答
その他の回答 (1 件)
Jorge Peñaloza Giraldo
2015 年 7 月 10 日
0 投票
1 件のコメント
Star Strider
2015 年 7 月 10 日
My pleasure! ¡El gusto is mío!
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!