How to have Matlab read files and then record the title of the file as a variable?

5 次查看(过去 30 天)
Hi everyone,
I have a set of files in a folder, like:
58.94177000.dpmrpt
62.586.dpmrpt
67.5467700.dpmrpt
77.331770000.dpmrpt
I need to read each file in Matlab, and record the title of the file like 77.331770000 as a variable, because it is a time variable.
Thank you.

采纳的回答

Walter Roberson
Walter Roberson 2022-4-10
S = {'58.94177000.dpmrpt', '62.586.dpmrpt'}
S = 1×2 cell array
{'58.94177000.dpmrpt'} {'62.586.dpmrpt'}
[~, timepart, ~] = fileparts(S)
timepart = 1×2 cell array
{'58.94177000'} {'62.586'}
  3 个评论
Walter Roberson
Walter Roberson 2022-4-10
projectdir = 'D:\data';
ext = ".dpmrp";
dinfo = dir(projectdir, "*" + ext);
filenames = fullfile({dinfo.folder}, {dinfo.name});
nfiles = length(filenames);
[~, timepart, ~] = fileparts(filenames);
for K = 1 : nfiles
thisfile = filenames{K};
thisdata = Function_To_Read_dpmrp_File_Goes_Here(thisfile);
results = Function_To_Process_Data_Goes_Here(thisdata);
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Identification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by