Info

This question is closed. Reopen it to edit or answer.

How to obtain values symbolically

1 view (last 30 days)
Vicky
Vicky on 22 Feb 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
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).

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 22 Feb 2013
Edited: Azzi Abdelmalek on 22 Feb 2013
EDIT
c=sym('c',[1 10])
x=sym('x')
f=@(x,n)sum(c(1:n).*x.^(1:n))
f(x,5)
  8 Comments
Vicky
Vicky on 23 Feb 2013
there should be sth else, but i cant find the answer...thank You, Walter, anyway.

bym
bym on 23 Feb 2013
alternative:
c =sym(1:10)
f = @(x) sum(c.*x.^(1:length(c)));

Community Treasure Hunt

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

Start Hunting!