2013-10-17 66 views
1

随着定点许可证,很容易在Matlab中创建任意定点数据类型,即与16个小数位的符号32位数:Matlab的创建类型的变量fixdt

custom_sfix = fixdt(1,32,16) 

custom_sfix = 

Simulink.NumericType 
    DataTypeMode: 'Fixed-point: binary point scaling' 
     Signedness: 'Signed' 
     WordLength: 32 
    FractionLength: 16 
     IsAlias: false 
     DataScope: 'Auto' 
     HeaderFile: '' 
    Description: '' 

如何创建在MATLAB中这种类型的值?

对于内置的类型,它只是a = int8(5);a = uint32(45); 我也试过类型转换,但这似乎只接受内置的数据类型。

>> Y = typecast(12.5, custom_sfix) 
Error using typecast 
The second input argument must be a character array. 

>> Y = typecast(12.5, 'fixdt(1,32,16)') 
Error using typecast 
Unsupported class. 

回答