How to expand a summation with different indexes

How to expand a summation with different indexes like this?
Any help would be appreciated.

댓글 수: 4

Don't post the same question every 23 minutes.
what about 24 or 18?
@SooShiant: Please stop posting the same question again and again.
@Stephen Cobeldick
That was different. This is numerical but that one you deleted was symbolical. Don't you know the symbolical answer?

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

답변 (4개)

Thorsten
Thorsten 2015년 10월 2일

1 개 추천

sum(diff(f(1:4)).*n(1:3).*arrayfun(@(x) sum(m(x:end)), 3:5))

댓글 수: 7

I pasted that code to matlab and it said:
Error using mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.
Error in sym/subsref (line 1580)
B = mupadmex('symobj::subsref',A.s,inds{:});
Thorsten
Thorsten 2015년 10월 2일
편집: Thorsten 2015년 10월 2일
The code works only if you have vectors f, n and m and numerically evaluate the sum, not symbolically.
So is it mean I can't have an algebraic equation at the end? And matlab cant do that?
Thorsten
Thorsten 2015년 10월 2일
편집: Thorsten 2015년 10월 2일
No. It just means that I gave you the wrong, i.e, numerical answer because I overlooked that by asking to "expand" you asked for a symbolical solution. In the future such mistakes could be avoided if you define your variables as sym and ask for a symbolical solution.
By the way thanks for your time. It would be the best if you write that code for me, because I am new to matlab and I have to drive a large 28-line equation and don't know how to do it.
@Thorsten : nice solution exploiting fact that each sum is independent of the other index, i and j, we may use dot products to compute the inner loop, and repeat it again for index i. I wonder if there is also a way to do it with mesgrid() and matrix products.
@Muthu Annamalai: don't you know the symbolical code?

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

Sean de Wolski
Sean de Wolski 2015년 10월 2일
편집: Sean de Wolski 2015년 10월 2일

0 개 추천

sum(diff(f(1:4)).*n(1:3).*sum(m(3:5)))

댓글 수: 5

Thorsten
Thorsten 2015년 10월 2일
편집: Thorsten 2015년 10월 2일
No. sum over m depends on i in the formula, but is a constant of value sum(m(3:5)) in the code.
I pasted this code to matlab and it said:
Error: Expression or statement is incorrect--possibly unbalanced (, {, or
[.
Thorsten, i is 1:3 for the example so I could hardwire j.
Thorsten
Thorsten 2015년 10월 2일
편집: Thorsten 2015년 10월 2일
Sean, yes, i is 1:3, so the starting index of j is 3:5, so the sum runs for j = 3:5 for i = 1, j = 4:5 for i = 2, and j = 5 for i = 3, i.e., assumes values sum(m(3:5)), sum(m(4:5)) and sum(m(5)) for i=1,2,3. You forgot to sum over the different m(j), as far as I can see.
Ah, so I need to tril() that part.

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

SooShiant
SooShiant 2015년 10월 2일

0 개 추천

As I said I want a code to expand summation (algebraic) not to get a numerical answer. How bad is it. There is no way. May I need to try Mathematica. Can any one help with Mathematica?

댓글 수: 3

I've seen this page before but as I said I'm new to matlab and need an emergency help. May you write down this code for me pleeeeeease??????????
Unfortunately I don't have the symbolic toolbox.

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

SooShiant
SooShiant 2015년 10월 2일

0 개 추천

I need Matlab answer me:
I wonder how you experts can't writes such a simple code. May it relates to Matlab capabilities and should use Mathematica. Can anyone help with Mathematica?

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2015년 10월 2일

댓글:

2015년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by