How to make a summation with index vector?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adriano
am 11 Mai 2018
Bearbeitet: Guillaume
am 11 Mai 2018
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 Kommentare
Akzeptierte Antwort
Guillaume
am 11 Mai 2018
Bearbeitet: Guillaume
am 11 Mai 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!