Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
a little help, please -- I keep getting a row of ones --

Subject: a little help, please -- I keep getting a row of ones --

From: staticd

Date: 29 Aug, 2010 16:13:03

Message: 1 of 5

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

Subject: a little help, please -- I keep getting a row of ones --

From: Roger Stafford

Date: 29 Aug, 2010 16:57:03

Message: 2 of 5

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

Subject: a little help, please -- I keep getting a row of ones --

From: staticd

Date: 29 Aug, 2010 19:25:01

Message: 3 of 5

Indeed, k, is the boltzman constant, which is k = 8.62e-5.

This is still pretty small...

It seems that I am finding out that precision is getting the best of
me...

I will try what you said and see what happens...

Subject: a little help, please -- I keep getting a row of ones --

From: Roger Stafford

Date: 29 Aug, 2010 20:59:04

Message: 4 of 5

staticd <staticd@gmail.com> wrote in message <bdd9ffed-ecea-4848-865b-b3877a7164a1@d8g2000yqf.googlegroups.com>...
> Indeed, k, is the boltzman constant, which is k = 8.62e-5.
>
> This is still pretty small...
>
> It seems that I am finding out that precision is getting the best of
> me...
>
> I will try what you said and see what happens...
- - - - - - -
  Using V = 10, I get 'exponent' equal to about 4.12e-17, which means that e to that power would be about 1 + 4.12e-17. This is beyond the accuracy capabilities of the double precision floating point numbers used by matlab. The answer would very likely show up as an exact 1 after rounding occurs. You need to use the symbolic toolbox with something higher than sixteen digit accuracy to get useful results with the numbers you are using.

Roger Stafford

Subject: a little help, please -- I keep getting a row of ones --

From: staticd

Date: 30 Aug, 2010 01:01:38

Message: 5 of 5

Thanks a bunch, Roger. I actually switched values for k (in terms of
J/Kelvin) and found the results I was looking for (ideal diode
characteristics).

:)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us