MATLAB: Solve Symsum equation for implied discount rate

cash flowsdiscount factorsolvesymsum

Dear All,
I am trying to solve for a discount rate which sets the net present value to a specific value.
Stream = [-20000, 2000, 2500, 3500, -5000, 6500,...
9500, 9500, 9500];
syms x k real;
eqn = symsum(Stream(1,k)*(1+x)^-k,k,1, length(Stream)) == 5274;
solx = solve(eqn,x)
Could anyone help to get the exact number for x?
Thanks in advance!

Best Answer

symsum() cannot be used for indexing. Create a vector of symbolic values and sum() that.
eqn = sum(Stream .* (1+x).^-(1:length(Stream))) == 5274