Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: a little help, please -- I keep getting a row of ones --
Date: Sun, 29 Aug 2010 16:57:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 37
Message-ID: <i5e3gv$m2c$1@fred.mathworks.com>
References: <957a8127-43ce-4040-9ffd-9c75735ebf57@i13g2000yqe.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1283101023 22604 172.30.248.37 (29 Aug 2010 16:57:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 29 Aug 2010 16:57:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:665929

staticd <staticd@gmail.com> wrote in message <957a8127-43ce-4040-9ffd-9c75735ebf57@i13g2000yqe.googlegroups.com>...
> Hello.  I am new to matlab, but would like to increase my
> understanding for future use!
> 
> Here is the deal: I riase a row of contstants to the power of a
> function and I get a row of ones!
> 
> Here is the code:
> 
> Inot = 1.0e-9
> T = 300
> V = (-10:0.1:10)
> n = 1.5
> q = 1.60e-19
> exponent = ( (q.*V) / (n*k*T) )
> e = repmat(exp(1),1,length(V))
> 
> Now, I have two row vectors and I want to raise one to the power of
> the other one, element by element.
> 
> >>> e.^exponent
> 
> This gives me a row of 201 "1"s.
> 
> >>> exp(exponent)
> 
> Same result.
> 
> What am I doing wrong?  I am definitely missing something here.
> 
> Any help is appreciated.
> 
> -s
- - - - - - - 
  You haven't told us what k is, but unless it is very small in magnitude all the values in 'exponent' are extremely close to zero and therefore e to that power must consequently be extremely close to one.  Try expressing the values to sixteen places and you may see that they are not exact ones.  Or try first multiplying 'exponent' by say 1e10 and you may see some deviation from exact ones in the answer.  Remember, the binary floating point numbers matlab uses are accurate to only about one part in 1e16.

Roger Stafford