Problem with writing sigma notation

조회 수: 1 (최근 30일)
Maath AlMulhim
Maath AlMulhim 2022년 9월 22일
답변: ag 2023년 9월 4일
Hi guys
I have an algorithm that gives me error in matlab when implmenting.
the algorithm is for mobile crowd sensing that link tasks with workers
The matrix G store the worker score . Each worker has strategy profile of tasks that are linked to him in a matrix S. Now, the worker's score under strategy is expressed as in the attached image. Moreover, the algorithm is showing the goal of the platform (that is proposed in the paper) of maximizing the workers scores. To have clearer imagination about the proposed platform in the paper, you can check the attachments.
When I run the code, I tried to write it as follows:
for i=1:T
for j=1:W
G(S)=(sigma(i,j)(G)(S)) % eq 11
end
end
for i=1:T
for j=1:W
max(G)=symsum(i,j)(G(i)(S)) % eq 12
end
end
It shows me this error:
Error: File: June_2022_exer.m Line: 120 (where eq 11 is written)
Column: 7
Invalid array indexing.
As you see, I tried ti implement sigma notation in two ways.
Kindly help

답변 (1개)

ag
ag 2023년 9월 4일
Hi,
I understand that you need to calculate the sum of the values returned by function "G" for values of "i" ranging from 1 to "n" for a given value of "j".
To achieve this, you can use a for loop in MATLAB. Here is an example of how to implement it:
value_of_G_at_j = 0;
for i = 1 : n
value_of_G_at_j = value_of_G_at_j + G(i, j);
end
Please note that in this approach, I assume that "G" is a function that takes "i" and "j" as input variables and returns a single integer value.
The "symsum" function can be used for symbolic vectors or matrices, and not for functions. For more details on "symsum" you can refer to the below documentation:
https://www.mathworks.com/help/symbolic/sym.symsum.html
Hope this helps!
Regards,
Aryan Gupta

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by