Hi everyone, can someone help me with this double sum ?
20 次查看(过去 30 天)
显示 更早的评论
Hi everyone, I am struggling on how to write this double sum in matlab, hoping someone can help me:
thanks in advance !!
1 个评论
回答(1 个)
John D'Errico
2022-10-7
编辑:John D'Errico
2022-10-7
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 个评论
John D'Errico
2022-10-8
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!