Files are not loading into my program

Hi,
i've got a problem with loading files into my matlab program, i dont really know what am i doing wrong and why i have error like that, can you tell me what should i change? I need to load files with informations into the program and make some graphs in that but main problem is with loading

Answers (1)

Stephen23
Stephen23 on 10 Feb 2023
Edited: Stephen23 on 10 Feb 2023
"i dont really know what am i doing wrong..>"
You are using LS() instead of DIR().
LS() is intented for a pretty display, not for iterating over. In contrast, the output of DIR() is very easy to iterate over.
"...can you tell me what should i change?"
Use DIR() not LS(), just as the MATALB documentation shows:
For example:
P = 'absolute or relative path to where the files are saved';
S = dir(fullfile(P,'*.csv'));
for k = 1:numel(S)
F = fullfile(S(k).folder,S(k).name);
T = readtable(F);
% do whatever you want with table T
end

Categories

Products

Release

R2022b

Asked:

on 10 Feb 2023

Edited:

on 10 Feb 2023

Community Treasure Hunt

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

Start Hunting!