fundamental multiplication problems with Matlab2010-2011!!!!

Dear all!
today I discover something very very very stupid in Matlab.0 This is the code I wrote:
x =
8.4600
>> y=x*10000
y =
8.4600e+004
>> y-84600
ans =
1.4552e-011
HOW THIS IS POSSIBLE????? it's only a multiplication!

3 comentarios

Jan
Jan el 30 de Ag. de 2012
Editada: Jan el 30 de Ag. de 2012
An evergreen question. See Answers: Search FAQ6.1
Hello, I just discovered that a lot of people have this problem. Actually when I met this problem, I even don't know what should I look for, what kind of key word I should put in google :p. I am just a basic user of matlab...
Jan
Jan el 30 de Ag. de 2012
@gringorie: You are in a good company - otherwise this topic would be discussed in the "seldom asked questions". Reading the FAQ is a good idea for all software you use, because it is worth to profit from the problems of others.

Iniciar sesión para comentar.

 Respuesta aceptada

gringoire
gringoire el 30 de Ag. de 2012
Dear Lucas,
Thank you very much for the link. But I am a little bit currious that if i want to use for exmaple the command ismember , how can I deal with this issue ? Do I need to write the whole algorithm with a tolerance ? And it also means I cannot use == for all the future applications when I get number like 1.234 ?
Thank you
Gringoire

4 comentarios

Many thanks.
Actually I am not an advance user of MATLAB just for some basic application in Matlab. What I want to do is just to identify the numbers in a text file , find out the same numbers compared to my calculation and list them. And I found ismember is very useful. May I change the floating number to the other type of number in order to evaluate the action or not?
Matt Fig
Matt Fig el 30 de Ag. de 2012
Editada: Matt Fig el 30 de Ag. de 2012
Your response is not an answer to the original question, so why did you choose it as the accepted answer??
Did you read the article in the link? It tells you how to deal with tolerances. The whole point of the article you were given was to make you aware of the issues involved with floating point numbers. I suggest you read it.
Yes. It means you can't use ismember to get reliable results with floating points.
For the most part when there is something common like this you will have no reason to reinvent the wheel:
Thank you very much Lucas! I will look for Walter myself!

Iniciar sesión para comentar.

Más respuestas (1)

For educational purposes:
>> x = 8.46
x =
8.4600
>> num2strexact(x)
ans =
8.46000000000000085265128291212022304534912109375
>> y = x * 10000
y =
8.4600e+004
>> num2strexact(y)
ans =
8.4600000000000014551915228366851806640625e4
>> y - 84600
ans =
1.4552e-011
>> num2strexact(ans)
ans =
1.4551915228366851806640625e-11
You can find num2strexact here:
href = ""<http://www.mathworks.com/matlabcentral/fileexchange/22239-num2strexact-exact-version-of-num2str</a>>

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 30 de Ag. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by