Azzera filtri
Azzera filtri

plotting with for loop for many text files

1 visualizzazione (ultimi 30 giorni)
Hello all, I am tyring to use MATLAB at work to plot about 800 text files, all having identical column format (so the same textscan function on each one) and the code below adequately plots ONE of these text files for me, my question is how would I model my for loop to load each text file one by one and spit out a different tiff image in my results folder. These text files all share a similar name (MT_00050-000 through MT_00250-000 ETC)
clear all
close all
clc
cd('C:\Documents and Settings\dgraham\Desktop\G-SUSX U65 text')
mkdir('results')
fid = fopen('MT_00063-000.txt');
datacell = textscan(fid, '%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','HeaderLines',600);
fclose(fid);
cd('C:\Documents and Settings\dgraham\Desktop\G-SUSX U65 text\results')
%define variables based on datacell
Altitude = datacell{1,22}*3.2808399;
time = datacell{1,4};
temperature = datacell{1,5};
%%%%%START OF PLOTS %%%%%
figure('position', [0 0 800 1100], 'PaperPositionMode', 'auto');
blah blah blah subplots using variables from datacell.
saveas(gcf,'results1.tiff')
%%%%%END OF PLOTS %%%%%

Risposta accettata

Rick Rosson
Rick Rosson il 6 Apr 2012
for k = 50:250
inputFileName = sprintf('MT_%05i-000.txt',k);
outputFileName = sprintf('results%05i.tiff',k);
...
fid = fopen(inputFileName);
...
fclose(fid);
...
saveas(gcf,outputFileName);
...
end

Più risposte (1)

Walter Roberson
Walter Roberson il 6 Apr 2012

Categorie

Scopri di più su Data Import and Export in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by