aswan 发表于 2008-11-6 11:12

浮点转定点的问题

弱问一下,在matlab里面怎么把浮点型数据转成定点的,有没有现成的函数阿??matlab默认的数据类型是双精度浮点型,我的想法是定义一个跟浮点型一样大小的定点数据,然后通过赋值强制转换过来,可是不知道定点型数据咋定义,请高手指点阿感激涕零

sogooda 发表于 2008-11-6 11:25

simulink里提供了转化方法,matlab里不知道怎么弄。


Fixed-Point Data Type and Scaling Notation


The following table provides a key for various symbols that may appear in Simulink products to indicate the data type and scaling of a fixed-point value.

Symbol

Description

uint

Unsigned integer fixed-point data type

sint

Signed integer fixed-point data type

ufrac

Unsigned fraction fixed-point data type

sfrac

Signed fraction fixed-point data type

ufix

Unsigned generalized fixed-point data type

sfix

Signed generalized fixed-point data type

fltu

Doubles-override of an unsigned fixed-point data type

flts

Doubles-override of a signed fixed-point data type

B

Bias

E

2^

e

10^

F

Fractional slope

n

Negative

p

Decimal point

S

Slope


Example: Port Data Type Display


For example, to display the data types of ports in your model, select Port/Signal Displays -> Port Data Types from the Simulink Format menu.

The port display for fixed-point signals consists of three parts: the data type, the number of bits, and the scaling. The data type and number of bits reflect the block's Output data type parameter value or the data type that is inherited from the driving block or through backpropagation. The scaling reflects the block's Output scaling value parameter value or the scaling that is inherited from the driving block or through backpropagation.

The model below displays its port data types:



The data type display associated with the In 1 block in the model indicates that the output data type is sfix(16) (a signed, 16-bit, generalized fixed-point number) with scaling of . Note that this scaling is not the block's default scaling. The data type display associated with the In 2 block indicates that the output data type is sfix(16) with binary point-only scaling of 2^-6.

sigma665 发表于 2008-11-6 18:08

看不太明白

vpa?

科技在线 发表于 2008-11-7 14:20

matlab有这个吗,记得c语言里面有

aswan 发表于 2008-11-10 17:30

搞定了,最后还是在C里面解决了,matlab里面也是可以进行数据类型强制转换的,只是转换过来以后运算就出问题了

liumilan 发表于 2008-12-17 21:19

有这样一个函数能直接转化为定点num2fixpt
在matlab可以做
在C语言怎么写啊

wickay 发表于 2010-7-28 10:25

请问一下,aswan

aswan,请问一下,你是怎么解决的转换问题的,是在MATLAB中用C代码实现的吗?
页: [1]
查看完整版本: 浮点转定点的问题