Matlab中fopen,fscanf,num2str的用法总结

fopen - Open file, or obtain information about open files
    This MATLAB function opens the file, filename, for binary read access, and
    returns an integer file identifier equal to or greater than 3.
    fileID = fopen(filename)
    fileID = fopen(filename,permission)
    fileID = fopen(filename,permission,machinefmt,encodingIn)
    [fileID,errmsg] = fopen(___)
    fIDs = fopen('all')
    filename = fopen(fileID)

    [filename,permission,machinefmt,encodingOut] = fopen(fileID)

fopen打开文件,或获取有关打开文件的信息。

这个MATLAB函数打开文件,文件名,用于二进制读取访问,以及。返回等于或大于3的整数文件标识符。


 fileID = fopen(文件名)


 fileID = fopen(文件名,许可)


 fileID = fopen(文件名,许可,machinefmt encodingIn)


 fIDs = fopen('all')
  filename = fopen(fileID)
[filename,permission,machinefmt,encodingOut] = fopen(fileID)

 

num2str:

函数功能:
把数值转换成字符串, 转换后可以使用fprintf或disp函数进行输出。在matlab命令窗口中键入doc num2str或help num2str即可获得该函数的帮助信息。
  
语法格式:
  str = num2str(A)
  把数组A中的数转换成字符串表示形式。
  str = num2str(A, precision)
  把数组A转换成字符串形式表示,precision表示精度, 比如precision为3表示保留最多3位有效数字, 例如0.5345转换后为0.534,1.2345转换后为1.23。即从左边第一个不为0的数开始保留3个数值。
  str = num2str(A, format)
  按format指定格式进行格式化转换,通常'%11.4g'是默认的。

相关函数:
mat2str, int2strstr2num, sprintf, fprintf

应用举例:
  >> A = [1, 2, 3];
  >> B = num2str(A);
  >> fprintf('%s', B)
  1 2 3>>
  >> C = [1.564, 0.12345];
  >> D = num2str(C, 3)
  D =
  1.56 0.123
  >> D = int32(1)
  D =
  1
  >> num2str(D, '%.6f')
  ans =
  1.000000

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值