Effacer les filtres
Effacer les filtres

plotting with for loop for many text files

1 vue (au cours des 30 derniers jours)
douglas
douglas le 6 Avr 2012
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 %%%%%

Réponse acceptée

Rick Rosson
Rick Rosson le 6 Avr 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

Plus de réponses (1)

Walter Roberson
Walter Roberson le 6 Avr 2012

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by