forming matrices depending on file name
1 次查看(过去 30 天)
显示 更早的评论
I have matlab files in a folder and there are, for example, several that have file names that start with M1, several that start with M9, several that start with M13, etc. I want to group the ones that start with the same letter and number into the same matrix and create separate matrices for different file names.
What matlab functions can I use to do this using for loops????
Thank you for your help in advance!
3 个评论
Rik
2020-10-29
If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks).
回答(1 个)
Jemima Pulipati
2020-12-14
Hello,
From my understanding, you want to retrieve all the files which start with a particular string into one structure.
Example:
cd myfolder
s1 = dir ('M1*.m');
s2 = dir('M2*.m');
This code returns all the matlab files which start with 'M1' inside the folder 'myfolder' into a struct array 's1'. Similarly, all the files which start with 'M2' are retrieved into 's2' struct array.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!