char array comparison

1 Ansicht (letzte 30 Tage)
Sam Da
Sam Da am 15 Mär. 2011
I have a large char array and these are dates so the array has elements as: 20070801 20070802 20070803 etc.
This array shows up as 100x8 in the workspace. I want to get all the dates which are less than 20070915. How do I use the 'find' function to achieve this or any other straight forward method?

Akzeptierte Antwort

Paulo Silva
Paulo Silva am 15 Mär. 2011
a=['20070801';'20070802';'20070803']; %some date values
b=20070802; %value to compare
a(find(str2num(a)<b),:) %date values older than the compared value

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 15 Mär. 2011
You could datenum() the dates and compare them to datenum() of your search date.

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by