# Hi everyone, can someone help me with this double sum ?

4 views (last 30 days)
marco bosisio on 7 Oct 2022
Commented: John D'Errico on 8 Oct 2022
Hi everyone, I am struggling on how to write this double sum in matlab, hoping someone can help me:
Torsten on 7 Oct 2022
Edited: Torsten on 7 Oct 2022
You cannot refer to a summation index j in the outer sum which is not yet defined.
So your double sum as written makes no sense.
Maybe you mean to flip the summation signs.

John D'Errico on 7 Oct 2022
Edited: John D'Errico on 7 Oct 2022
Surely you can use a loop? Actually just nested loops? Perhaps your problem is MATLAB does not allow a zero index, yet you have what would seem to be a zero index.
Next, are those powers of S and T?
Anyway, all you need to do is
ThisSum = 0;
for j = 0:4
for i = 0:4-j
ThisSum = ThisSum + a(i+1,j+1)*T^i*S^j;
end
end
I assume that a is an array, since you have what apear to be indices. And a would need to be a 5x5 array.
Are there other ways to solve this? Well, yes. Do you need them? NO.
##### 2 CommentsShowHide 1 older comment
John D'Errico on 8 Oct 2022
How would I know either? Your formula refers to an array that appears to have TWO indices, i and j. But you tell us that a is just a 1x15 vector. Without knowing what the elements of a are, or what they mean, they are just a list of numbers. Perhaps it really was an array, in some unrolled form. But without knowing exactly what a contains, or why it is that shape, we are left with no answer. A list of numbers contains no meaning associated with it. The meaning can only be derived from the person or programmer that created the list.
That it is a 15 element vector MIGHT be related to the fact that if you took only the upper or lower triangle of a 5x5 array, there would be exactly 15 elements. But that would be pure and wild conjectiure on my part, and I would still not know in which order those elements are taken. I cannot read the mind of the programmer who created this vector.

### Categories

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!

Translated by