How can I generate this recurrence formula a
(0)=1;a(1)=0;a(2)=3;a(3)=1/6;for n=2:28;a(n+2)=((6/((n+1)*(n+2)))*sum(a(i)*a(n-i);i=0..n));end

댓글 수: 9

Walter Roberson
Walter Roberson 2019년 10월 2일
Add one to each index, because you cannot use 0 as an index.
Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
Thank you
Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
Could you help me and write full code for my problem, please!
James Tursa
James Tursa 2019년 10월 2일
What is the text of your assignment?
a(0+1)=1;a(1+1)=0;a(2+1)=3;a(3+1)=1/6;for n=2:28;a(n+2+1)=((6/((n+1)*(n+2)))*sum(a(i+1)*a(n-i+1);i=0..n));end
Except that you need to figure out how to rewrite the sum(a(i+1)*a(n-i+1);i=0..n)) part . Hint: use .* instead of * and vectorize
Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
Still I have a problem
Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
This is called differential transform method for solving initial value problem
As I wrote, you need to figure out how to rewrite the sum(a(i+1)*a(n-i+1);i=0..n)) part. MATLAB does not offer any syntax for summation that uses variable=lower..upper notation (not unless you get fairly far into how the Symbolic Toolbox actually works.) MATLAB offers a symbolic summation of the form
symsum(SYMBOLIC_EXPRESSION, SYMBOLIC_VARIABLE, LOWER_BOUND, UPPER_BOUND)
however, the SYMBOLIC_VARIABLE cannot be used to index any array. symsum() is not intended for summation of a small finite number of terms: it is intended for creating formulas, such as
symsum(m^2, m, 1, n)
to get out the formula for the sum of squares of the first n numbers.
You need to find a different way to do the summation of indexed variables.
Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
Thank you Mr Walter

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

답변 (1개)

James Tursa
James Tursa 2019년 10월 2일

0 개 추천

MATLAB indexing is 1-based, not 0-based. You will need to adjust your indexing:
a(1) = 1;
a(2) = 0;
:
etc

댓글 수: 4

Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
Mr James, this is a part of solution of an initial value problem using differential transform method
John D'Errico
John D'Errico 2019년 10월 2일
That is irrelevant. You cannot index a variable at index 0.
Shadi Al-Ahmad
Shadi Al-Ahmad 2019년 10월 2일
Mr John, could you help me and write full MATLAB code for my problem, please?
You need to find a different way to do the summation of indexed variables.
Hint: use .* instead of * and vectorize
Hint:
>> A = [1 3 5 7]; A(1:3) .* A(2:4)
ans =
3 15 35

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

카테고리

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

질문:

2019년 10월 2일

댓글:

2019년 10월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by