How to read in a file automatically through loop?

6 ビュー (過去 30 日間)
Ifigenia Aslanidou
Ifigenia Aslanidou 2019 年 8 月 22 日
コメント済み: Ifigenia Aslanidou 2019 年 8 月 25 日
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 Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by