现在的位置: 首页 > 综合 > 正文

Matlab int 类型的最大值 等号转变了类型

2013年11月04日 ⁄ 综合 ⁄ 共 250字 ⁄ 字号 评论关闭

matlab 中使用 int类型时要注意两点:

1. temp = uint8(0) 默认 temp的最大值将是255, 

2. ‘=’ 号不仅赋值,而且赋类型。(害的我好惨)

如下:

>> temp8 = uint8(255)

temp8 =

  255

>> temp8 = temp8 + 1

temp8 =

  255

>> temp16 = uint16(255)

temp16 =

    255

>> temp16 = temp16 + 1

temp16 =

    256

>> temp16 = temp8

temp16 =

  255

>> temp16 = temp16 + 1

temp16 =

  255

>> 

抱歉!评论已关闭.