필터 지우기
필터 지우기

the number of files between two elements of a cell

조회 수: 6 (최근 30일)
Ishak Oussama
Ishak Oussama 2019년 2월 2일
댓글: Ishak Oussama 2019년 2월 5일
Hi, I want to know the number of * .inf files between two elements of a cellthe number of * .inf files between two elements of a cell
here is my example in this picture ,so I want to indicate a start date and an end date
after i want to have the number of files that exists between these two dates, taking into account all the files have the same dates
here is an example:
start_date=20190102
end_date=20190128
we need a program that verifies just the first six characters of each name or else, I'm lost

채택된 답변

Stephen23
Stephen23 2019년 2월 3일
편집: Stephen23 2019년 2월 3일
An effiicent method based on simple logical comparisons of numeric vectors (serial date numbers):
>> d1 = '20190102';
>> d2 = '20190128';
>> n1 = datenum(d1,'yyyymmdd')
n1 =
737427
>> n2 = datenum(d2,'yyyymmdd')
n2 =
737453
>> num = datenum(regexp(matchList,'^\d{8}','once','match'),'yyyymmdd')
num =
737427
737447
737448
737455
737456
>> idx = n1<=num & num<=n2
idx =
1
1
1
0
0
>> nnz(idx)
ans =
3
  댓글 수: 3
OCDER
OCDER 2019년 2월 4일
Yup, Stephen is right. My answer doesn't work for different months and years. I'll delete that answer so that others don't use it. The use of datetime is much better.
Ishak Oussama
Ishak Oussama 2019년 2월 5일
(Stephen Cobeldick) thank you very much for your answer, I am a beginner in matlab, so I voted and accepted your answer.
I have another question about that , I want to make a graphical interface with pop-up menu
I want to put d1 as follows:
pop -up menu for day
pop -up menu for -month
pop -up menu for -year ,and same thing for d2 using your solution
and display the result in an edit txt

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by