Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!hg8g2000vbb.googlegroups.com!not-for-mail
From: Greg Heath <heath@alumni.brown.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Summing numbers in an M file in MATLAB
Date: Thu, 12 May 2011 16:16:14 -0700 (PDT)
Organization: http://groups.google.com
Lines: 17
Message-ID: <0b2050ae-beca-466f-95fa-c7a4c9e91c33@hg8g2000vbb.googlegroups.com>
References: <iqh4s8$em7$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 69.242.101.137
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1305242174 5694 127.0.0.1 (12 May 2011 23:16:14 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 12 May 2011 23:16:14 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: hg8g2000vbb.googlegroups.com; posting-host=69.242.101.137; posting-account=mUealwkAAACvQrLWvunjg50tRAnsNtJR
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:726497

On May 12, 1:20 pm, "J.C.  Martinez" <beatbox...@gmail.com> wrote:
> here's my code. I'm wondering what else I need to add to sum up all the numbers at the end.
>
> a = input('Enter number of days you would like to know the total of');
> f(1) = .01;
> for i = 2:a
>     f(i) = (2*f(i-1));
> end
>
> Would sum(sum(2:a)) work right before the "end"?

I think you want sum(f) after the end

Hope this helps.

Greg