【问题标题】:Matlab file concatenationMatlab 文件连接
【发布时间】:2018-03-15 00:16:33
【问题描述】:

我有这样的数据文件

2 FP1 0 9.064
2 FP1 1 6.622
2 FP1 2 4.669
2 FP1 3 3.693
2 FP1 4 3.693
2 FP1 5 3.693
2 FP1 6 4.181
2 FP1 7 4.181
2 FP1 8 5.157
2 FP1 9 6.134
2 FP1 10 7.111
2 FP1 11 7.111
2 FP1 12 5.646
2 FP1 13 4.669
2 FP1 14 3.693
2 FP1 15 4.181

其中有几个文件,我想将所有文件与这些数据连接起来;我使用了以下内容:

d=dir('*.m');  % get the list of files
x=[];            % start w/ an empty array
for i=1:length(d)
x=[x; load(d(i).name)];   % read/concatenate into x
end
save('newfile.m',x) 

但是,我收到以下错误,

 Error using load
  Unknown text on line number 1 of ASCII file co2a0000364.rd.002.m
 "FP1".

如何连接所有文件中的所有数据并包含字符 FP1 等?

【问题讨论】:

  • 数据在.m文件中???

标签: matlab file concatenation


【解决方案1】:

使用 load() 从文本文件中读取数据是错误的。使用 load() 加载保存的 Matlab 变量。使用 importdata()

https://de.mathworks.com/help/matlab/ref/importdata.html

或查看以下选项

https://de.mathworks.com/help/matlab/import_export/ways-to-import-text-files.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 2023-03-09
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    相关资源
    最近更新 更多