Undefined function 'exp' for input arguments of type 'uint8'
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kobi
el 15 de Feb. de 2014
because i use a big variables (matrics in the size of 20e3 by 20e3), i found that by changing the variables to uint8 for example:
s2=uint8(s2);
i am able to run the script without any MEMORY related errors, and my computer doesn't freez, also the calculation is much faster and the variable memory size is about 400MB compering to GB using double.
now i have a new problem while running my script i get this error:
Undefined function 'exp' for input
arguments of type 'uint8'.
i have to use the exp! what can i do?
0 comentarios
Respuesta aceptada
John D'Errico
el 15 de Feb. de 2014
Editada: John D'Errico
el 15 de Feb. de 2014
Very simple. Use smaller matrices. Or, get a larger computer, with more RAM. Either size your problems to fit your hardware, or get better hardware.
There are good reasons why EXP is not defined for UINT8 input. Really, it makes no sense at all to compute exp for UINT8 numbers, especially with this size array if you cannot store it in memory as a double. For example...
exp(0:10)
ans =
1 2.7183 7.3891 20.086 54.598 148.41 403.43 1096.6 2981 8103.1 22026
Note that the result will NOT be integer except when the input is 0. If you tried to store it as UINT8 by rounding, almost all results would overflow the datatype anyway.
I think it is time to rethink what you are doing by trying to compute the exponential in this context.
(By the way, IF you did intend to compute the result for UINT8 input, it would be highly wasteful to apply an exponential to the entire array of that size. Since there are only 256 possible inputs, use a lookup table. Thus compute all values of exp(0:255), then all that is needed is a matrix index into the table just computed.)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!