How to obtain values symbolically

Hi! Im using Matlab version 7.9.0(R2009b) and i would like to sum e.g. first 10 terms of expression c_i*x^i, where c_i should be obtained symbolically. how should i do that, so that this expression is dependent on x / function of x (so when i enter exact number for x, i get real number - not expression with c_i).

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 22 日
編集済み: Azzi Abdelmalek 2013 年 2 月 22 日

0 投票

EDIT
c=sym('c',[1 10])
x=sym('x')
f=@(x,n)sum(c(1:n).*x.^(1:n))
f(x,5)

8 件のコメント

Vicky
Vicky 2013 年 2 月 23 日
yes, but i get sum like this x*(c5*x^4 + c4*x^3 + c3*x^2 + c2*x + c1). And if i enter for x=2; i get 2*c1 + 4*c2 + 8*c3 + 16*c4 + 32*c5.. but i would like to get number...real number. i know its strange; that because i dont understand what means "obtain c_i symbolically"...
Walter Roberson
Walter Roberson 2013 年 2 月 23 日
Note: R2009b does not allow sym('c', [1 10])
Walter Roberson
Walter Roberson 2013 年 2 月 23 日
2*c1 + 4*c2 + 8*c3 + 16*c4 + 32*c5 would be the answer to the question based on the information you have given us. You might possibly have been given other information that defined c_i that you did not happen to share with us.
Vicky
Vicky 2013 年 2 月 23 日
again, i got the following instructions: 'you have the sum from 1 to Infinity of c_i*x^i, denoted with f(x). using Symbolic Math Toolbox evaluate f(x), summing the first 150 terms of the series, where the c_i are obtained symbolically. second part (that is now not important) is: then use zero-finder to determine the largest value of x, such that the bound -log(1-f(x))/x do not exceed u=2^(-53)'. thats all i have. how should i solve it?
Vicky
Vicky 2013 年 2 月 23 日
and the result is then the largest value x, that is real number.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 23 日
Ity seems like a homework, I think you get enough help to finish the work.
Walter Roberson
Walter Roberson 2013 年 2 月 23 日
If that is the complete instruction you are given, then the c_i are just the symbolic variables, and you will not be able to complete the second part.
If there are instructions before that point, then you might be able to proceed further.
Vicky
Vicky 2013 年 2 月 23 日
there should be sth else, but i cant find the answer...thank You, Walter, anyway.
bym
bym 2013 年 2 月 23 日

0 投票

alternative:
c =sym(1:10)
f = @(x) sum(c.*x.^(1:length(c)));

この質問は閉じられています。

質問済み:

2013 年 2 月 22 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by