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

10 Ansichten (letzte 30 Tage)
marco bosisio
marco bosisio am 7 Okt. 2022
Kommentiert: John D'Errico am 8 Okt. 2022
Hi everyone, I am struggling on how to write this double sum in matlab, hoping someone can help me:
thanks in advance !!
  1 Kommentar
Torsten
Torsten am 7 Okt. 2022
Bearbeitet: Torsten am 7 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 7 Okt. 2022
Bearbeitet: John D'Errico am 7 Okt. 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 Kommentare
marco bosisio
marco bosisio am 7 Okt. 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 am 8 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by