Use symsum with non-integer step?

조회 수: 6 (최근 30일)
Stephen Jackson
Stephen Jackson 2016년 3월 30일
답변: Walter Roberson 2016년 3월 31일
Is it possible to use symsum with a non-integer step? If not, what is a summation work around for using non-integer steps in order to sum over a function?
Here is what I currently have. This is part of a double summation, but the second summation done has it's bounds set by the value of the first summation bounds so I had to use a for loop on that first summation. If you have any input on how to better do the double summation on this, feel free to share.
nn = 0:step:Nmax;
for z = 1:length(nn)
in = L(i)-abs(N(j)-nn(z));
ll = L_le:step:abs(in);
Ll = 0;
func = sqrt((L(i) - Ll + 0.5).^2-(N(j) - nn(z) - 0.5).^2)/((L(i) - Ll + 0.5).*(N(j) - nn(z) - 0.5))...
- sqrt((L(i) - Ll + 0.5).^2-(N(j) - nn(z) + 0.5).^2)/((L(i) - Ll + 0.5).*(N(j) - nn(z) + 0.5));
R = symsum(func,Ll,ll)*A(j,i)*B(j,i)*C(j,i)*Cp(j,i) + R;

답변 (1개)

Walter Roberson
Walter Roberson 2016년 3월 31일
No, the underlying symbolic engine only accepts integer steps.
Use integer indices but replace the variable with a function of the index variable that return the appropriate value. For example,
LL = @(IDX) L_e + (IDX-1) * step;

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by