adding some single elements in matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Dear Prof/Dr./Sir./Maam
I have matrix A=[1 2 3 4 5] and B=[ 6 7 8 9]. I want to calculate s1=1+2+6 s2=2+3+7 s3=3+4+8 s4=4+5+9.
Is it possible to calculate the elements from different matrix like that?
Thank you in advance
0 件のコメント
採用された回答
sudobash
2022 年 7 月 29 日
Hi!
So as per my understanding, 2 consecutive elements of A need to be added and the resulting vector needs to be added to B.
A possible solution could be like this:
A=[1 2 3 4 5];
B=[ 6 7 8 9];
Asum = A(2:end) + A(1:end-1)
final = Asum + B
Hope this solves your question.
その他の回答 (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!