?? 首頁-matlab-數(shù)據(jù)處理-一個(gè)文件數(shù)據(jù)處理小程序.txt
字號(hào):
首頁-MATLAB-數(shù)據(jù)處理-一個(gè)文件數(shù)據(jù)處理小程序 2004年
9月6日
星期一
首頁 發(fā)表論文 自制軟件 串口通訊 VC/C編程 網(wǎng)絡(luò)通訊 機(jī)器人控制 MATLAB
數(shù)據(jù)文件處理小程序
程序作者:黃文宇博士 整理:龔建偉
在實(shí)驗(yàn)中,處理記錄數(shù)據(jù)文件是經(jīng)常要做的,而用Matlab來處理是我最推崇的,方便快捷,數(shù)據(jù)文件格式任意設(shè)置,均可處理,如用下面格式保存的數(shù)據(jù)文本data.txt,用Matlab來處理,用黃文宇博士這個(gè)小程序做來非常容易,而且處理后得到的圖形可直接Copy到各種需要的文件中。
data.txt文件:
......
d+00005.00;v+00001.92;e+00003.08;u-0016;m+1004;t+0286;
d+00005.00;v+00002.06;e+00002.94;u-0041;m+0988;t+0287;
d+00005.00;v+00002.19;e+00002.81;u-0040;m+0947;t+0288;
d+00005.00;v+00002.31;e+00002.69;u-0033;m+0907;t+0289;
d+00005.00;v+00002.39;e+00002.61;u-0024;m+0874;t+0290;
d+00005.00;v+00002.47;e+00002.53;u-0024;m+0850;t+0291;
d+00005.00;v+00002.56;e+00002.44;u-0025;m+0826;t+0292;
d+00005.00;v+00002.61;e+00002.39;u-0016;m+0801;t+0293;
d+00005.00;v+00002.69;e+00002.31;u-0024;m+0785;t+0294;
d+00005.00;v+00002.72;e+00002.28;u-0007;m+0761;t+0295;
.....
處理函數(shù)readprocess
function readprocess(file)
fid=fopen(file,'rt');
if(fid==-1)
display('File not exist!');
return;
end
array=[];
while(~feof(fid))
str=fscanf(fid,'%s',1);
if(length(str)>10)
%d+00005.00;v+00002.72;e+00002.28;u-0007;m+0761;t+0295;
col=sscanf(str,'d%f;v%f;e%f;u%f;m%d;t%d;');
array=[array col];
end
end
fclose(fid);
dhead=array(1,:);
head=array(2,:);
'r:',t,head,'b-');
運(yùn)行環(huán)境,Matlab5X
使用方法:readprocess data.txt
你可以根據(jù)需要處理。
回到頁頂
嘯峰工作室 龔建偉制作維護(hù) 轉(zhuǎn)載本站內(nèi)容 請(qǐng)注明作者 并說明來自 http://roaringwind.best.163.com 嘯峰工作室
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -