Is it possible to have a vector that full of decimal data in it, and sum them up.

Is it possible to have a vector or matrix that full of decimal data in it, and sum them up. Because Matlab gives me an error saying "Subscript indices must either be real positive integers or logicals." Here is my code.
Exact=((pi)^(4))/90;
a=1:1:20000;
n=ones(1,20000);
c=n./(a.^4);
f=sum(c,'double'); Error happens here: "Subscript indices must either be real positive integers or logicals."
Ef=Exact-f;
I really want to do it in the vector or matrix way. Maybe anyone show me another way.

Answers (1)

maybe you did something like sum=12 which destroy your function, try to clear it
clear sum
Exact=((pi)^(4))/90;
a=1:1:20000;
n=ones(1,20000);
c=n./(a.^4);
f=sum(c,'double');
Ef=Exact-f

1 Comment

Exactly. After "sum=12" the function of this name is shadowed. You can check this by:
whos sum

Sign in to comment.

Products

Asked:

on 27 Oct 2012

Community Treasure Hunt

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

Start Hunting!