MATLAB: Reading through folders getting the warning : .” Index in position 1 exceeds array bounds (must not exceed 1).”.

MATLAB and Simulink Student Suitemultiple folders

Hello
The answer might be failry easy, but i am kind of stuck in it.
I'm trying to run through multiple subforlders to get a plot which contains data from all these folder. The goal is to compare the results.
But I get the Warning: " Index in position 1 exceeds array bounds (must not exceed 1). " in the second step when reading the files.
D_rough = 'C:\Users\ammar\OneDrive\Dokumenter\Master 2019\waves\Analysis\DATA_WAVE BASIN\Rough';
directories = dir(D_rough,'dir*');
12.JPG
I hope you can help 🙂

Best Answer

At some point, did you define a variable named dir? MATLAB would then try to access that variable, rather than the command. Clear that variable, and see if it works.