How to make a summation with index vector?

3 ビュー (過去 30 日間)
Adriano
Adriano 2018 年 5 月 11 日
編集済み: Guillaume 2018 年 5 月 11 日
Hi! I need to solve this summation in Matlab:
where N is a constant and s is a matrix YxN. I tried to use symsum function but I can't index the s matrix. Anyone can help me? Many thanks!
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 5 月 11 日
If s is Y x N then what is s subscript t ?
Adriano
Adriano 2018 年 5 月 11 日
編集済み: Adriano 2018 年 5 月 11 日
Sorry the matrix is a TxN. I'm working with a time serie so that the row is usually indicated with t. Suppose I have a matrix like:
s = [1 2; 3 4; 5 6] where N = size(s,2)
I need to create a vector Z in which the first element is:
value_1_1 = (1*s(1,1) - (1/N)) + (2*s(1,2) - (2/N));
the second one is:
value_2_1 = (1*s(2,1) - (1/N)) + (2*s(2,2) - (2/N));
and so on. Obviously in the reality the s matrix is a very large matrix so that I need a simple way to calculate it.

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

採用された回答

Guillaume
Guillaume 2018 年 5 月 11 日
編集済み: Guillaume 2018 年 5 月 11 日
I need to create a vector Z in which the first element is:
col = 1:size(s, 2);
Z = sum(col .* s - col/N, 2); %requires R2016b or later
Note that the sum 1/N + ... N/N could be extracted from the formula since it's a constant equal to (N+1)/2, so a simplification of the above would be:
Z = sum(col .* s) - (size(s, 2)+1)/2;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by