- Load the table
- Use datetime to create Date from first 3 columns. Add hours(column 4) to it to complete datetime
- Create variable for elevation data
- Use table to combine Date and Elev
- Format the date
Combine date and time
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Amra Rajuli
am 1 Jun. 2021
Kommentiert: Amra Rajuli
am 4 Jun. 2021
I have 5 coloumn data consist year, month, date, hour and elevation data. I want to merge the data into two coloumn so it become:
coloumn1(datetime) coloumn 2
YYYY-MM-DD HH:mm:ss Elevation Data
I have tried some examples from matlab forum, but it not work. I used 2016b matlab version. Can anyone help me? Thank you.
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 1 Jun. 2021
The best way to combine data types (datetime and numeric) is to use a table. There are several possible approaches. Here is one.
data = readmatrix("tidal data.txt");
Date = datetime(data(:,1:3)) + hours(data(:,4));
Elev = data(:,5);
T = table(Date,Elev);
T.Date.Format = 'yyyy-MM-DD HH:mm:ss'
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interface-Based Instrument Communication 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!