資源簡介
將混合有字符串和數據的文件,在matlab中讀取,提取數據信息。
運用腳本,適合批量讀取,而非手動插入數據。
代碼片段和文件信息
clear;
clc;
clf;
fclose(‘all‘);
format?long
%?---?file?name?---
num?=?1;
%?str?=?sprintf(‘data-%03d-.txt‘?num);
str?=?‘data1b.txt‘;
fid?=?fopen(str);
if?fid<0
????error(‘no?file?is?opened‘);
end
i?=?3;
j?=?1001;
%?---?number?of?curves?---
k?=?76;
%?===?save?===
Data?=?zeros(j2k);
p?=?i;
q?=?p+j-1;
n?=?1;
m?=?1;
filestr?=?sprintf(‘%03d.txt‘m);
filefid=fopen(filestr?‘w‘);
while?~feof(fid)
????
????line?=?fgetl(fid);
????
????if?n>q
????????fclose(filefid);
????????m?=?m+1;
????????if?m?>?1
??????
- 上一篇:灰色預測模型通用matlab代碼
- 下一篇:mtlab灰色系統建模MGM1,n模型
評論
共有 條評論