matlab的textscan,matlab中textscan函数的使用记录

%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是要转化的时间戳的单元格。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值