Multiple specific elements in an array
10 ビュー (過去 30 日間)
表示 古いコメント
I have a matrix [a b c d e f g]. I want to sum [2*(a + b) + 3*(c+d) +4*(e+f)]. How do i go about doing this ?
0 件のコメント
回答 (1 件)
Bhaskar R
2020 年 2 月 20 日
Assuming a, b,c, d, ..g are values in the vector say X
X = 1:7;
sum([2:4].*[sum(reshape(x(1:6), 2,3))]);
参考
カテゴリ
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!