필터 지우기
필터 지우기

anyway to compare date in Matlab

조회 수: 11 (최근 30일)
Yu Li
Yu Li 2019년 3월 20일
댓글: Star Strider 2019년 3월 21일
I have two file with the same name, but different location, for example:
file1: D:/test/abc.m
file2: E:/test/abc.m
one of them has been updated. I could check the last modified name by:
filenames1=dir'(D:/test/);
time_file1=filenames(3).date;
filenames2=dir'(E:/test/);
time_file2=filenames(3).date;
the 'time_file1' and 'time_file2' represents the last modified time of these two files, the format is like: '22-Jan-2019 08:43:06'
my question is:
is there anyway to know which is ealier/later, so that I can keep the latest one for use, with out left-click, then property, to look at.
Bests,
Yu

채택된 답변

Star Strider
Star Strider 2019년 3월 20일
It might be easier to use the datenum field instead if you simply want to compare dates:
filenames1=dir'(D:/test/);
time_file1=filenames(3).datenum;
filenames2=dir'(E:/test/);
time_file2=filenames(3).datenum;
datediff = time_file1 - time_file2;
  댓글 수: 4
Yu Li
Yu Li 2019년 3월 21일
Hi:
Thanks for your reply.
one point can not assure the judgement is right. I think knowing the internal method of how these two translate between each other would be more reasonable.
I'm contacting Mathworks Tech Support regarding it, and will come back here after I receive a appropriate solution.
Bests,
Yu
Star Strider
Star Strider 2019년 3월 21일
My pleasure.

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

추가 답변 (1개)

Pruthvi G
Pruthvi G 2019년 3월 20일
[~,Data] = dos('dir D:/test/abc.m');
Scanned_data = textscan(Data,'%s');
Date_modified = Scanned_data{1}{15};

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by