%example.txt内容:
Student_ID | Test1 | Test2 | Test3
1 91.5 89.2 77.3
2 88.0 67.8 91.0
3 76.3 78.1 92.5
4 96.4 81.2 84.6
%%%%%%%%%%%%%%%%%%%
fileID = fopen('example.txt');
formatSpec = '%s';
N = 4;
%将文件头一行的数据名称读入
C_text = textscan(fileID,formatSpec,N,'Delimiter','|');
C_data0 = textscan(fileID,'%d %f %f %f');
%%%%%%%%%%%%%%%%%%%%%
fileID = fopen('example.txt');
%过滤前两行,按格式读入四列数据
C_data0 = textscan(fileID,'%d %f %f %f', 'headerlines', 2);
%%%%%%%%%%%%%%%%%%%%%%
fileID = fopen('example.txt');
%过滤前两行并过滤后三列,只读入第一列
C_data0 = textscan(fileID,'%d %*f %*f %*f', 'headerlines', 2);
%等同上面一句 C_data0 = textscan(fileID,'%d %*[^\n]', 'headerlines', 2);
fclose(fileID);
%name.txt内容:
"Smith, J.","M",38,71.1
"Bates, G.","F",43,69.3
"Curie, M.","F",38,64.1
"Murray, G.","F",40,133.0
"Brown, K.","M",49,64.9
%%%%%%%%%%%%%%%%%%%%
fileID = fopen('names.txt','r');
%读取第一列和最后一列过滤中间两列,%q to read a string enclosed by double quotation marks "string"
% %q读取由双引号括起来的字符串 "string"
C = textscan(fileID,'%q %*q %*d %f','Delimiter',',');
fclose(fileID);
%data2.csv内容:
abc, 2, NA, 3, 4
// Comment Here
def, na, 5, 6, 7
fileID = fopen('data2.csv');
C = textscan(fileID,'%s %n %n %n %n','Delimiter',',',...
'TreatAsEmpty',{'NA','na'},'CommentStyle','//');
fclose(fileID);
xls行数较多时公式下拉很慢,如何快速填充公式:
按下SHIFT+CTRL+方向键下,再在编辑栏里输入公式,再按下CTRL+回车;
excel怎么样批量将unix时间戳转化为北京时间:
选中其中一个单元格,输入公式
=(A2+8*3600)/86400+70*365+19, 如果单元格中的时间单位是ms则 =(A2/1000+8*3600)/86400+70*365+19)
其中,A2是要转化的时间戳的单元格。
网友评论