Borrar filtros
Borrar filtros

plotting with for loop for many text files

1 visualización (últimos 30 días)
douglas
douglas el 6 de Abr. de 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 %%%%%

Respuesta aceptada

Rick Rosson
Rick Rosson el 6 de Abr. de 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

Más respuestas (1)

Walter Roberson
Walter Roberson el 6 de Abr. de 2012

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by