Load mat files matching specific string inclusive of different strings

조회 수: 4 (최근 30일)
Mohammed Yousuf
Mohammed Yousuf 2021년 9월 26일
댓글: KSSV 2021년 9월 26일
I have a folder which consist of n number of .mat files, the names of the files are like mentioned below (latest residuals in log10 of year 2002 to 2020, altitude, latitude , longitude)
latest_res_log102002_alt
latest_res_log102002_lat
latest_res_log102002_long
latest_res_log102003_alt
latest_res_log102003_lat
latest_res_log102003_long
.
.
.
.
latest_res_log102020_long
I would like to load the files three at a time when required by searching the year only. viz.
latest_res_log102015_alt, latest_res_log102015_lat and latest_res_log102015_long.
How to do that. PLease help me.
  댓글 수: 1
Mohammed Yousuf
Mohammed Yousuf 2021년 9월 26일
latest_res_log102002_alt.mat
latest_res_log102002_lat.mat
latest_res_log102002_long.mat

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2021년 9월 26일
matFiles = dir('*.mat') ;
matFiles_name = {matFiles.name} ;
idx = find(~cellfun(@isempty,strfind(matFiles_name,'2015'))) ;
matFiles_name(idx)
  댓글 수: 4
Mohammed Yousuf
Mohammed Yousuf 2021년 9월 26일
Yes, but i want to load only the files which consist of the year which i want,
viz. If I wnat only 2005 files
then I should load only latest_res_log102005_alt.mat ; latest_res_log102005_lat.mat; latest_res_log102005_long.
KSSV
KSSV 2021년 9월 26일
Then instead of 2015 give log102005. Change the string to your requirement.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by