How to read in a file automatically through loop?

5 次查看(过去 30 天)
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 个评论
Ifigenia Aslanidou
Ifigenia Aslanidou 2019-8-25
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 2019-8-25
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;

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scope Variables and Generate Names 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by