How can you rearrenge a large datafile to....

Hi guys
I have a large .txt file witch I load in matlab (x,y,z coordinates for a ship), but the point is I will use matlab to generete the point so it is an input into another software. The other sofware can't handle all the points in the .txt file, so I need to have a code who can rearrenge the .txt file into a smaller one. Otherwise it is very time consuming doing manually. I'm thinking something like take the every 50. set of x,y,z and make a new matrix.
Hope you understand my issue...

 採用された回答

Ingrid
Ingrid 2015 年 5 月 7 日

1 投票

instead of using load, you could use textscan to read in the txt file
endNotReached = true;
counter = 1;
fid = fopen(stringTextLocation);
while endNotReached
rawData = textscan(fid,'%f%f%f', 50);
if size(rawData,1) < 50
endNotReached = false;
end
fidWrite = fopen(['data' num2str(counter) '.txt'],'w');
fprintf(fidWrite,'%f%f%f\n',rawData);
fclose(fidWrite)
counter = counter + 1;
end
fclose(fid)

2 件のコメント

Isa Ilkan Duran
Isa Ilkan Duran 2015 年 5 月 7 日
Excellent !!!
Ingrid
Ingrid 2015 年 5 月 7 日
編集済み: Ingrid 2015 年 5 月 7 日
by the way, whe are not all guys here ;-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2015 年 5 月 7 日

編集済み:

2015 年 5 月 7 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by