MATLAB: Does the NUMEL function give an incorrect answer for a uint8 datatype, when run in the script in MATLAB 6.5.1 (R13SP1)

acceleratorelementsjitlengthMATLABnumbernumelofuint8

When I execute the following code I receive the incorrect output value for "a" shown below:
data=uint8(randn(245,352,11))
data_whos = whos( 'data' )
a= numel(data)
data_whos =
name: 'data'
size: [245 352 11]
bytes: 948640
class: 'uint8'
a =
86240
The correct value of "a" should be 245 x 352 x 11=948640.
However, when I run the code through the MATLAB debugger I get the correct answer.

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This issue has been fixed in MATLAB 7.0 (R14). If you are using an earlier version of MATLAB, read the following:
We have verified that there is a bug in MATLAB 6.5.1 (R13SP1) that affects the way the JIT accelerator handles the NUMEL function for uint8 datatypes.
To work around this issue, try disabling the JIT accelerator temporarily. This can be done as follows:
data=uint8(randn(245,352,11))
data_whos = whos( 'data' )
feature('accel', 'off') % Disabling the accelerator before implementing NUMEL
a= numel(data )
feature('accel', 'on') % Turning the accelerator back to "on"