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

17 views (last 30 days)
Hi everyone, I am struggling on how to write this double sum in matlab, hoping someone can help me:
thanks in advance !!
  1 Comment
Torsten
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.

Sign in to comment.

Answers (1)

John D'Errico
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 Comments
marco bosisio
marco bosisio on 7 Oct 2022
thank you very much for your quick answer,
the problem is that "a" is indeed an array but it is a 1x15 array, I am not sure on how to index it.
John D'Errico
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!