How to let Matlab fill in different date, string, and numbers in a table

2 Ansichten (letzte 30 Tage)
alpedhuez
alpedhuez am 10 Dez. 2020
Bearbeitet: Walter Roberson am 11 Dez. 2020
Suppose I have table T1
Date City Vistors
------------------
January 1 2020 NY 100
January 2 2020 NY 110
and table T2
Date City Vistors
------------------
January 4 2020 NY 130
January 5 2020 NY 140
Then I want to have
Date City Vistors
------------------
January 1 2020 NY 100
January 2 2020 NY 110
January 3 2020 NY 120
January 4 2020 NY 130
January 5 2020 NY 140
That is,
(1) I want to vertcat(T1,T2)
(2) Fill in missing date
(3) Fill in missing value for state with the same state name
(4) Fill in missing value for vistors with linear interporation
  10 Kommentare
Adam Danz
Adam Danz am 11 Dez. 2020
Maybe you could show us what you're trying to compare.
To summarize our suggestions so far,
  1. Vertically concatenate the tables assuming they have the same number of columns and same variable names (T=[T1;T2])
  2. Convert the City names from string to categorical (see categorical as dpb showed you)
Then you have 2 options,
  1. Use fillmissing , or
  2. Convert the table to timetable if it isn't already (see table2timetable) and use retime.
If you're stuck at one of those steps or one of these steps won't work with your data, please explain.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by