声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 4289|回复: 6

[编程技巧] 浮点转定点的问题

[复制链接]
发表于 2008-11-6 11:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

使用道具 举报

发表于 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 [Slope Bias] scaling of [0.2 10]. 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.
发表于 2008-11-6 18:08 | 显示全部楼层
看不太明白

vpa?
发表于 2008-11-7 14:20 | 显示全部楼层
matlab有这个吗,记得c语言里面有
 楼主| 发表于 2008-11-10 17:30 | 显示全部楼层
搞定了,最后还是在C里面解决了,matlab里面也是可以进行数据类型强制转换的,只是转换过来以后运算就出问题了
发表于 2008-12-17 21:19 | 显示全部楼层
有这样一个函数能直接转化为定点num2fixpt
在matlab可以做
在C语言怎么写啊
发表于 2010-7-28 10:25 | 显示全部楼层

请问一下,aswan

aswan,请问一下,你是怎么解决的转换问题的,是在MATLAB中用C代码实现的吗?
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-14 19:44 , Processed in 0.062813 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表