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

1 view (last 30 days)
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 Comments
Adam Danz
Adam Danz on 11 Dec 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.

Sign in to comment.

Answers (0)

Categories

Find more on Timetables in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!