how to load files which are listed in a cell array

1 view (last 30 days)
hello everyone,
I am doing aerodynamic computations. The blade i'm workin on is composed of several airfoils.
The airfoils data are contained into excel files. I have a total of 50 files.
However, i am trying to load each file for each section of the blade using for loop but i did not succeed.
I used the method given here:
Hence, i have the names of the files but i did not succeed to load each of the files.
Here the error i get:
>> names = dir('C:\........\BEMT_\airfoil_properties_*.xlsx');
>> filenames={};
>> filenames(3)
ans =
>> M=xlsread(filenames(3));
Error using xlsread (line 121)
File name must be a string.
Could you help me please ?
Best Regards

Accepted Answer

Rik on 3 Mar 2023
Edited: Rik on 3 Mar 2023
The filenames variable is a cell array, so you need {} to index the contents:
But it is better to use the struct returned by dir directly, as it allows you to include the path:
Rik on 4 Mar 2023
Just make sure to mention it next time (you can even put it in the release field when you ask a new question).
You need to use the same path you put in the dir call. I don't know a way to parse any wildcards for the folders.

Sign in to comment.

More Answers (0)


Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!