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, int2str, str2num, 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