主要内容

rescale

更改 fi 对象的定标

语法

b = rescale(a, fractionlength)

b = rescale(a, slope, bias)
b = rescale(a, slopeadjustmentfactor, fixedexponent, bias)
b = rescale(a, ..., PropertyName, PropertyValue, ...)

说明

rescale 函数的作用类似于 fi 复制函数,但有以下例外:

  • fi 复制构造函数保留真实值,而 rescale 保留存储整数值。

  • rescale 不允许更改 SignedWordLength 属性。

示例

在以下示例中,fi 对象 a 经过重新定标以创建 fi 对象 bab 的真实值不同,但它们的存储整数值相同:

p = fipref('FimathDisplay','none',...
		'NumericTypeDisplay','short');
a = fi(10, 1, 8, 3)
a = 

    10
      numerictype(1,8,3)
b = rescale(a,1)
b = 

    40
      numerictype(1,8,1)
stored_integer_a = storedInteger(a);
stored_integer_b = storedInteger(b);
isequal(stored_integer_a,stored_integer_b) 
ans =

  logical

   1

扩展功能

全部展开

C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。

HDL 代码生成
使用 HDL Coder™ 为 FPGA 和 ASIC 设计生成 VHDL、Verilog 和 SystemVerilog 代码。

版本历史记录

在 R2006a 之前推出

另请参阅