Hi all,
I am trying to read some data collected. I made a mistake and inputted 07/24/2023 instead of 07/23/2023. Now the matlab date which is in a number format is unable to correctiy read the data based on these timestamps.
Please, I will apprciate it if any one can help me adjust the matlab date 07/23/2023 to 07/24/2023 or any suggestions will be appreciated.
NOTE: the malab date is in a number format eg. 7.390905000610648e+05

 Akzeptierte Antwort

Voss
Voss am 23 Jul. 2023
Bearbeitet: Voss am 23 Jul. 2023

0 Stimmen

"the malab date is in a number format eg. 7.390905000610648e+05"
The number format is the number of days since Jan 0, 0000 (see: datenum), e.g.:
datenum('07/23/2023')
ans = 739090
datenum('07/24/2023')
ans = 739091
"help me adjust the matlab date 07/23/2023 to 07/24/2023"
In order to adjust the date forward by one day (e.g., from 07/23/2023 to 07/24/2023), you can add 1 to the number.
num = 739090.5000610648;
datetime(num,'ConvertFrom','datenum')
ans = datetime
23-Jul-2023 12:00:05
num = num+1;
datetime(num,'ConvertFrom','datenum')
ans = datetime
24-Jul-2023 12:00:05
(If you want to go from 07/24/2023 to 07/23/2023, you would subtract 1. Your question says you want to do both.)

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by