Finding substring based on another substring
2 次查看(过去 30 天)
显示 更早的评论
I have a bunch of data files and can get all of their names via
D = dir('*.mat');
Each name has a couple of numbers in it in the format '*num1_###*num2_###*.mat' where ### is the actual number.
I can set num1 equal to some value, say 1.7, and then get all assotiated files i.e.
D = dir('*num1_1.7*)
essentially getting a row of num2 files for num1 = 1.7 if you think of num1 and num2 making a grid of values.
What is the most efficient way to get files along the diagonal? I.e. where num1 is equal to num2, but the values aren't known a priori.
For example, if I have the files
num1_1_num2_1.mat num1_2_num2_1.mat num1_3_num2_1.mat
num1_1_num2_2.mat num1_2_num2_2.mat num1_3_num2_2.mat
num1_1_num2_2.mat num1_2_num2_3.mat num1_3_num2_3.mat
from dir(), how can I extract
num1_1_num2_1.mat, num1_2_num2_2.mat, num1_3_num2_3.mat?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!