Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: can you help me find the mistake here
Date: Thu, 14 Oct 2010 20:15:10 +0000 (UTC)
Organization: MetaRock Laboratories
Lines: 36
Message-ID: <i97oce$l06$1@fred.mathworks.com>
References: <i97ktj$295$1@fred.mathworks.com> <i97m34$ikt$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1287087310 21510 172.30.248.35 (14 Oct 2010 20:15:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 14 Oct 2010 20:15:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1625843
Xref: news.mathworks.com comp.soft-sys.matlab:678552

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i97m34$ikt$1@fred.mathworks.com>...
> "salamay " <coldfusion99@gmail.com> wrote in message <i97ktj$295$1@fred.mathworks.com>...
> > In the following code  i need to get s1 = s2. I believe s1 is correct but not s2. Can someone tell me what am I doing wrong to compute the summation s2
> > 
> > 
> > s1=0; l=0.0127; h=6; P = 170; Po = 177; t = 3*3600; phi = 0.025; uc = 1.62e-11;
> > beta = [127.391000000000    372.323000000000    619.187000000000    866.339000000000    1113.58700000000    1360.87900000000    1608.19600000000    1855.52600000000    2102.86500000000    2350.21100000000    2597.56200000000    2844.91500000000]
> > 
> > for n = 1:length(beta)
> >     s1 = s1 + (exp(-1e-25*beta(n)^2*t/(phi*uc))/(l*(beta(n)^2 + h^2)+h))
> > end
> > s2 = sum(exp((-1e-25*beta.^2*t)/(phi*uc))/(l*(beta.^2 + h^2)+h))
> > 
> > Result:
> > s1 =
> > 
> >    0.005790696529312
> > 
> > 
> > s2 =
> > 
> >     1.474478992007853e-005
> - - - - - - - - - - -
>    In s2 you are lacking the dot in the division operation.  It should read
> 
> s2 = sum(exp((-1e-25*beta.^2*t)./(phi*uc))/(l*(beta.^2 + h^2)+h))
> 
> This is necessary to obtain element-by-element divsions rather than matrix division which is a different operation.
> 
> Roger Stafford

Oh you are a life saver.

It drove me nuts and i didn't realize

Thanks Roger