matlab怎么读32位16进制数,怎样把dsp出来的32位16进制的数据转换为十进制的数matlab...

使用fscanf函数完成。

例如 .dat文件如下 第一行为文本的信息

1651 1 10004 1 7fe0

0x0000

0xC8F4

......

读取的方法:  fid = fopen('mydata.dat');%文本在当前工作目录

result = fscanf(fid,'%x');

完成后result即数据,但是数据开头是文本第一行的信息   可以使用a = result(5:length(result)-5)去掉

关于fscanf

format

String enclosed in single quotation marks that describes each type of element (field). Includes one or more of the following specifiers.

Field Type Specifier Details

Integer, signed

%d

Base 10

%i

Base determined from the values. Defaults to base 10. If initial digits are 0x or 0X, it is base 16. If initial digit is 0, it is base 8.

%ld or %li

64-bit values, base 10, 8, or 16

Integer, unsigned

%u

Base 10

%o

Base 8 (octal)

%x

Base 16 (hexadecimal)

%lu, %lo, %lx

64-bit values, base 10, 8, or 16

Floating-point number

%f

Floating-point fields can contain any of the following (not case sensitive): Inf, -Inf, NaN, or -NaN.

%e

%g

Character string

%s

Read series of characters, until find white space.

%c

Read any single character, including white space.

(To read multiple characters, specify field length.)

%[...]

Read only characters in the brackets, until the first nonmatching character or white space.

Optionally:

To skip fields, insert an asterisk (*) after the percent sign (%). For example, to skip integers, specify %*d.

To specify the maximum width of a field, insert a number. For example, %10c reads exactly 10 characters at a time, including white space.

To skip a specific set of characters, insert the literal characters in the format. For example, to read only the floating-point number from 'pi=3.14159', specify a format of 'pi=%f'.

参考文档:http://www.mathworks.cn/cn/help/matlab/ref/sscanf.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值