Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sum of exponentials
Date: Sat, 24 Nov 2012 17:28:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <k8r036$nn7$1@newscl01ah.mathworks.com>
References: <k8l6sb$2fj$1@newscl01ah.mathworks.com> <k8lqar$4po$1@newscl01ah.mathworks.com> <k8o2mg$pdp$1@newscl01ah.mathworks.com> <k8o3vo$ia$1@newscl01ah.mathworks.com> <k8onag$2kt$1@newscl01ah.mathworks.com> <k8qlsv$ktj$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-06-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1353778086 24295 172.30.248.38 (24 Nov 2012 17:28:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 24 Nov 2012 17:28:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:783402

"dwi" wrote in message <k8qlsv$ktj$1@newscl01ah.mathworks.com>...
> Ok, I understand now how this works. But still, you said the result will be
> x(3)+x(2)*e^(-1)+x(1)*e^(-2))/(1+e^(-1)+e^(-2));
> while I want
> (x(3)*e^(-1)+x(2)*e^(-2)+x(1)*e^(-3))/(e^(-1)+e^(-2)+e^(-3));
> Also, how would your code change if I had e^(-1/20), e^(-2/20), e^(-3/20) etc?
- - - - - - - - 
  The two expressions

 (x(3)*e^(-1)+x(2)*e^(-2)+x(1)*e^(-3))/(e^(-1)+e^(-2)+e^(-3))

and

 (x(3)+x(2)*e^(-1)+x(1)*e^(-2))/(1+e^(-1)+e^(-2))


are identically equal.  Just divide the numerator and denominator of the first expression by e^(-1) to get the second expression.  What you want and what this code produces are the same thing.

  As to your second question, just the two lines

 a = x(k) + a*f*e^(-1);
 b =  1   + b*f*e^(-1);

would need to be changed to:

 a = x(k) + a*f*e^(-1/20);
 b =  1   + b*f*e^(-1/20);

Roger Stafford