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

回答(1 个)

"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

类别

帮助中心File Exchange 中查找有关 File Operations 的更多信息

产品

版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by