我有一個100個.dat文件就像一個在左側窗格中,我需要進口無頭,然後對行進行排序。導入無頭數據和重新排列列數據
答案通過文件做手工,文件:
data=sortrows(data,2); #sort all columns of data via the 2nd col
fid=fopen('pole_2_TurbI_chamber_05_RSM.xy');
[x ~] = textscan (fid, '%f %f', 'HeaderLines', 4); # reads file correctly
fclose(fid);
v(:,1)=cell2mat(x(:,1)); # convert from cell to array
v(:,2)=cell2mat(x(:,2));
v=sortrows(v,2); # sort rows according to column 2
% fig
plot(v(:,1),-v(:,2),'ro');
我怎麼能這樣延伸到我的目錄中的所有文件?也許給每個導入的變量文件名......如果可能的話。 問候,
你能不能把循環在你手動解決方案,使其自動解決方案? – Pursuit 2012-03-04 17:26:48