Undefined function 'exp' for input arguments of type 'uint8'
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
John D'Errico
2014-2-15
编辑:John D'Errico
2014-2-15
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!