Plotting large amounts of txt files then exporting results
2 ビュー (過去 30 日間)
古いコメントを表示
I am not adept at MATLAB, but I would like help in plotting data from several hundred .txt files and saving the plot results as a .tif or other easily readable file.
How do I import data from such a large amount of files, that share an identical layout, but may have a different amount of rows, then have each txt file plotted and exported as a readable file or pic? I want to save myself having to spend a lot of time doing each txt file individually.
0 件のコメント
採用された回答
Geoff
2012 年 3 月 22 日
You want to start with the dir command to find the contents of a directory.
indir = 'mydatadir\'; % or / if you are not using windows.
outdir = indir;
mkdir(outdir); % Ensure output dir exists
f = dir([indir '*.txt']);
for n = 1:numel(f)
basename = f(n).name(1:end-4); % remove .txt
infile = [indir f(n).name]
outfile = [outdir basename '.tiff'];
% now load the file and plot your chart as you would normally
%[TODO]
% save the chart (in this case it's gcf, but could be your own figure
print( gcf, '-dtiff', outfile );
end
This will output an image for each file, using the same base filename: ie data03.txt --> data03.tiff
Look at the documentation for print. I used -dtiff, but you could spit out a jpeg, png, or eps instead.
You'll probably want to change various parameters on your figures to set the size. Play around, and enjoy.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!