MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by C Zeng on 26 Oct 2012

Hi, all,

I defined an array like S=ones(N,x,'uint32'). And I give values to all of them. However I find out the maximum value is 65535 which is 2^16 not 2^32.

I tried 'uint64' but the limit is still 65535, why is that?

Thanks.

*No products are associated with this question.*

Answer by Image Analyst on 26 Oct 2012

Somewhere along the way, you must have converted it to uint16, perhaps without realizing that you did so.

Show 1 older comment

C Zeng on 26 Oct 2012

Thanks, Walter. I think it somewhere convert to double, however, double is more than uint32, right? Does it matter?

## 4 Comments

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/51915#comment_107366

How are you assigning the values?

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/51915#comment_107519

Oh, it is weird here. Let me try again.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/51915#comment_107531

Oh, when I use class, it is converted to uint16. I need to figure out why?

However I only define uint32 at the beginning. So what could be a reason for converting to uint16? I am confused.

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/51915#comment_107720

Calling class() causes

noconversion. It must have got converted some other way.