Subscript - Symbolic serie

조회 수: 3 (최근 30일)
Gennaro Arguzzi
Gennaro Arguzzi 2017년 8월 18일
댓글: Walter Roberson 2017년 8월 18일
Hello everyone. Is it possible to create a symbolic serie like this: a_0, a_1, a_2, a_3? I tried with the following wrong code:
close all
clear all
syms a n
x=symsum(a_{n},n,0,3)
Thank you very much.

채택된 답변

Walter Roberson
Walter Roberson 2017년 8월 18일
편집: Walter Roberson 2017년 8월 18일
a = [sym('a_0'), sym('a_%d', [1, 3])];
However, it is not possible to use a symbolic variable to index anything; in particular, the symbolic index, n, in symsum() cannot be used to index anything. You need to construct the individual terms and add them up, such as
x = sum( a .^ (1:4) )
  댓글 수: 2
Gennaro Arguzzi
Gennaro Arguzzi 2017년 8월 18일
Hi @Walter Roberson. The result is x=a_1^2 + a_2^3 + a_3^4 + a_0, instead of x=a_0+a_1+a_2+a_3. How can I get it? Thank you.
Walter Roberson
Walter Roberson 2017년 8월 18일
I was giving an example of how to create terms based upon the individual entries and then sum those terms. For your particular case, just
x = sum(a);

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by