Sum of defined portion of a 3D matrix

2 ビュー (過去 30 日間)
Matt
Matt 2015 年 9 月 22 日
コメント済み: Stephen23 2015 年 9 月 22 日
Hello,
I would like to sum different layers of a 3D matrix, but I don't know an easy way of doing it. Basically what I would like to do is this:
matrix1=sum(timematrix(:,:,1:3))
"timematrix" is a 1x1000x5 matrix and I would like to compute the sum of the first 3 layers. Using the following command works:
matrix1=timematrix(:,:,1)+timematrix(:,:,2)+timematrix(:,:,3)
Thanks in advance!

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 22 日
matrix1 = sum(timematrix(:,:,1:3), 3);
  1 件のコメント
Stephen23
Stephen23 2015 年 9 月 22 日
This is explained perfectly in the documentation:

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by