NAN+inf

2 visualizzazioni (ultimi 30 giorni)
x
x il 8 Set 2011
in my paper i need to calculate exp()...here in my code i got exp(4096) but due to this i am getting NAN+inf in all larger value areas..what to do for this?whether tis indicates any error or this NAN+inf for some values are acceptable?

Risposta accettata

Walter Roberson
Walter Roberson il 8 Set 2011
Which MATLAB version are you using?
Please use size() and iscomplex() on the result variable to see if it is perhaps a complex number.
If you are contemplating using values that large, you should check to see if you can find a way to rewrite the calculation using the log of the values instead. That will not always be possible but when values that large are being discussed, it is not uncommon for there to be a log transformation of the problem.
exp(4096) is, by the way, approximately 7.416480782e1778
If you must use such large values and it is not possible to do a log transformation, then you probably need to use the symbolic toolbox, possibly with a large Digits setting.
  10 Commenti
x
x il 8 Set 2011
plz .......help me sir......manually i found how this answer returns..but in matlab the value is inf only ..how to do it in matlab
Walter Roberson
Walter Roberson il 8 Set 2011
Use my large_exp() function instead of exp(), but then make appropriate adjustments for the fact that large_exp() returns a pair of numbers, the first being the mantissa, and the second being the power of 10.
But I still think it is more likely that you can work with the log() of the equations, never taking the exp() of 4096.

Accedi per commentare.

Più risposte (1)

Paulo Silva
Paulo Silva il 8 Set 2011
Can you please tell my why are you trying to get a result from exp(4096)? you do know that the result would be a very huge number, MATLAB can't find it.
  4 Commenti
x
x il 8 Set 2011
sqrt is complex at some cases..al the above conditions which you mentioned exists in my calculation sir..some of determinant value is negative tooo.how to solve this problem sir?
Walter Roberson
Walter Roberson il 8 Set 2011
What would you _like_ the result to come out as if the determinant turns out to be negative ?

Accedi per commentare.

Categorie

Scopri di più su Exponents and Logarithms in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by