I created a timetable. The first column is the timestamp, then followed by different variables measured over time. I want to plot a scatter plot by using the timestamp as my x-axis and a couple of other variables on my y-axis. I tried to convert my variables into a separate column out of the timetable so that I could call the vairables when plotting them with my timestamp. I tried to use splitvars to split my variables but it did not seem to work. Thanks!
MATLAB: How could I extract a column within a timetable
timetable
Related Solutions
I would suggest taking table 1 and transposing it so that your countries are your column headers, and dates are all in a column.
Convert all dates to datetimes.
Then just plot as you normally would with your dates as the X values. They will appear as datetimes in the plot.
One simple way to combine these variables is to add them together in a new timetable variable and delete the old variables.
For example, assuming the table looks something like this,
>> baz = synchronize(t1,t2)baz = 9×8 timetable UTC Freq_t1 FreqErr_t1 Vpk_t1 dBV_Vpk__t1 Freq_t2 FreqErr_t2 Vpk_t2 dBV_Vpk__t2 ____________________ _______ __________ ______ ___________ _______ __________ ______ ___________ 01-Jan-2020 00:00:00 9 10 8 4 4 NaN 3 2 01-Jan-2020 06:00:00 NaN 2 10 7 8 7 8 3 01-Jan-2020 12:00:00 2 NaN 7 2 8 7 3 NaN 01-Jan-2020 18:00:00 10 10 1 8 2 NaN 6 3 02-Jan-2020 00:00:00 7 5 9 1 5 2 NaN 9 02-Jan-2020 06:00:00 1 9 10 3 5 5 9 3 02-Jan-2020 12:00:00 3 NaN 7 1 7 10 10 10 02-Jan-2020 18:00:00 6 5 NaN NaN 8 4 6 4 03-Jan-2020 00:00:00 10 10 8 9 8 NaN 2 2
we can do
>> baz.FreqErr = sum([baz.FreqErr_t1 baz.FreqErr_t2],2,"omitnan");>> baz = removevars(baz,["FreqErr_t1","FreqErr_t2"])baz = 9×7 timetable UTC Freq_t1 Vpk_t1 dBV_Vpk__t1 Freq_t2 Vpk_t2 dBV_Vpk__t2 FreqErr ____________________ _______ ______ ___________ _______ ______ ___________ _______ 01-Jan-2020 00:00:00 9 8 4 4 3 2 10 01-Jan-2020 06:00:00 NaN 10 7 8 8 3 9 01-Jan-2020 12:00:00 2 7 2 8 3 NaN 7 01-Jan-2020 18:00:00 10 1 8 2 6 3 10 02-Jan-2020 00:00:00 7 9 1 5 NaN 9 7 02-Jan-2020 06:00:00 1 10 3 5 9 3 14 02-Jan-2020 12:00:00 3 7 1 7 10 10 10 02-Jan-2020 18:00:00 6 NaN NaN 8 6 4 9 03-Jan-2020 00:00:00 10 8 9 8 2 2 10
Best Answer