Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: sum of exponentials
Date: Fri, 23 Nov 2012 15:48:08 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 52
Message-ID: <k8o5ro$6ae$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>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1353685688 6478 172.30.248.37 (23 Nov 2012 15:48:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 Nov 2012 15:48:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3783529
Xref: news.mathworks.com comp.soft-sys.matlab:783344

"dwi" wrote in message <k8o3vo$ia$1@newscl01ah.mathworks.com>...
> "dwi" wrote in message <k8o2mg$pdp$1@newscl01ah.mathworks.com>...
> > "Roger Stafford" wrote in message <k8lqar$4po$1@newscl01ah.mathworks.com>...
> > > "dwi" wrote in message <k8l6sb$2fj$1@newscl01ah.mathworks.com>...
> > > > I have a matrix whose data are interrupted by sequences of zeros. I need every time that there's a zero value to substitute it with a sum of exponentials using the previous data, eg:
> > > > x=[x1 x2 x3 0 0 0 x7 0 0]
> > > > When i find the first zero in the element x4 I want:
> > > > x4=(x3*e^(-1)+x2*e^(-2)+x1*e^(-3))/(e^(-1)+e^(-2)+e^(-3));
> > > > However, when I find the second zero value I need to calculate the same expression but without using the previous recalculated values. That is,
> > > > x4=x5=x6
> > > > and for x8 I will use only the values in x7,x3,x2,x1 and then x8=x9 etc
> > > > And all this for a 180000-length data.
> > > > Any ideas on how to do this?
> > > > Thanks in advance
> > > - - - - - - - - -
> > >  a = 0; b = 0;
> > >  for k = 1:length(x)
> > >    if x(k) ~= 0
> > >      a = x(k) + a*e^(-1);
> > >      b =  1   + b*e^(-1);
> > >    else
> > >      x(k) = a/b;
> > >    end
> > >  end
> > > 
> > > Roger Stafford
> > Thank you for your answer but if I use this the index of the exponent never changes.I want it to decrease as k increases, and i don't know hot to calculate a sum like this.
> 
> A correction:
> x8=(x7*e^(-1))/e^(-1)
> ie without using x1,x2,x3 but only the immediate previous non-zero values

This is what I have so far:
s=0;
s1=0;
i=1;
while i<=length(x)
for j=1:length(x)
if x(i)~=0
s=s+????     %%%%%the numerator which I still don't know how to calculate
s1=s1+e^(-j);
i=i+1;
else
x(i)=s/s1;
i=i+1;
j=1;
s=0;
s1=0;
end
end
end
This seems to work fine for the denominator. ANy ideas about the numerator?