If I want to plot a function with summation, what should I do? The function is like
y = (1/0.5*x*(x-1))*summation(dij)

댓글 수: 4

Jan
Jan 2011년 2월 13일
Please specify the dimensions and type of x and dij and what you want to be summed.
yuen
yuen 2011년 2월 15일
i only know i and j is the distance between two nodes, d(ij) is defined as the distance of the nodes. I would like to find the sumation of d(ij)and only know that i>j. then , from the above equaton, how can i get the plot function. thanks for your help!!!plz!!
Jan
Jan 2011년 2월 15일
"i and j is the distance"? And "d(ij)" is the distance also? What exactly does "d(ij)" mean? You know that i>j - but you do not explain what i and j are. With this limited information it is impossible to create a meaningful answer.
yuen
yuen 2011년 2월 17일
sorry for making misunderstanding...in fact, i and j means two nodes, their distance is defined as d. Can you help me how to plot the function? thanks a lot.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2011년 2월 12일

1 개 추천

sum() does summation.
I cannot tell from from example exactly what you are trying to sum.

댓글 수: 8

yuen
yuen 2011년 2월 15일
only use sum? how about the defination i need to define? for i and j? they are distance, and i use d to replace.
Walter Roberson
Walter Roberson 2011년 2월 15일
You haven't been at all clear about what i and j should be for this purpose, but this might be what you need:
y = (1/0.5*x.*(x-1)) .* sum( reshape(bsxfun(@gt,(1:size(d,1)).', 1:size(d,2)) .* d,[],1))
yuen
yuen 2011년 2월 15일
what do you mean by sum( reshape(bsxfun(@gt,(1:size(d,1)).', 1:size(d,2)) .* d,[],1))?
is it a function?
Walter Roberson
Walter Roberson 2011년 2월 15일
bsxfun() is a matlab operation. In this context it is used to construct a lower-diagonal triangle of 1's and 0's, as your specification that all you know is that i>j could be interpreted as meaning you want the lower triangle of the matrix. Multiplying the triangle of 1's and 0's element-wise by d masks out the diagonal and upper triangle, leaving 0's and the values in the lower triangle. reshape() is then used to turn that 2D matrix in to a vector, and sum() then totals those values.
It can be done without the reshape by using sum(sum(bsxfun(@gt,(1:size(d,1)).', 1:size(d,2)) .* d))
yuen
yuen 2011년 2월 17일
sorry, i still don't understand what it mean, when i try to plot the function, it still has errors, what should i do?
yuen
yuen 2011년 2월 17일
also, what do you mean by d?
Walter Roberson
Walter Roberson 2011년 2월 17일
You referenced dij and you said something about i > j. That implied to me that you have a matrix named "d" with subscripts "i" and "j".
We need your code and any error messages you are encountering in order to take this any further.
yuen
yuen 2011년 2월 18일
I had sent to actually equation to your mail box. please check and really thank you a lot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

질문:

2011년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by