How to read in a file automatically through loop?

9 visualizaciones (últimos 30 días)
Ifigenia Aslanidou
Ifigenia Aslanidou el 22 de Ag. de 2019
Comentada: Ifigenia Aslanidou el 25 de Ag. de 2019
Hello everyone!
I need your help in finding a way to read in a a file each iteration.
My Folder looks like that:
and I want that each time it reads the file in order.
For example, for j=1--> reads in the first file
for j=2--> reads in the second file
.....and so on.
Until now, I used to read in the files every time manually,but I would like if my script could do it on its own to save time.
I appreciate any help :)
  12 comentarios
Ifigenia Aslanidou
Ifigenia Aslanidou el 25 de Ag. de 2019
I realised whichmight be causing the trouble: the S returns a Matrix : N x 6 instead of the measurements list..(struct)
Ifigenia Aslanidou
Ifigenia Aslanidou el 25 de Ag. de 2019
Ok now it worked!
Script:
clear all;
%% Pre-allocate the variables that will save ALL of the data
Preallocating_variables_save_all_data;
P = 'C:\Users\aslan\OneDrive\Desktop\Studienarbeit 2019\Messungen';
D = dir(fullfile('Messungen','*.mat')); %I dont know what the problem was because with S... instead of D it caused the troubles, when I ran it was a matrix,when I typed it it in command it... was a list
for j=1:6
%------------------------------INPUTS---------------------------------%
% Datei einlesen (Array "OUTPUT")
F = fullfile('Messungen',D(j).name); %replaced P with 'Messungen' (how the meas. file is... named after
T = load(F);
OUTPUT = T.OUTPUT;

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Scope Variables and Generate Names en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by