登录论坛

查看完整版本 : [MATLAB基础] 请教字符串数组转换成数值数组的问题?


godjohsn
2019-04-01, 14:59
文档(data.txt)内容如下:
1.123E-3
2.345E-4
2.345E-4
6.34E-4
3.2E-5
……

本意是将文档中的科学计数的数字转转成数值,再做进一步计算。

matlab里利用textread命令读取文档里的字符:
y=textread('data.txt','%s');
y_str=y';
y_data = str2num(y_str);


可是运行出错:
Error using str2num (line 32)
Requires string or character array input.


请问这种需求该如何写程序?
谢谢!