How can i add data from multiple tables?

3 views (last 30 days)
Oscar Rogneby
Oscar Rogneby on 6 Mar 2021
Answered: Aashita Dutta on 25 Jan 2022
I have a data set of six tables containing energy production.
They contain 2 rows and different number of columns.
Row 1 contains dates with different starting points, row 2 contains production values.
I have imported 6 tables, and added the range command to align the dates, as they have the same ending point.
They look like this.
V = readtable('Valsneset2006.xlsx','Range','A4:B4783');
S = readtable('Skomakerfjellet2016.xlsx','Range','A4:B4783');
The S matrix has over 3000 empty cells before it lines up with V, but i can't seem to find a better way to aling them.
I want to add the production numbers in row 2 of the different tables to view the total energy production each day.
How can i achieve this?
Thanks in advance!
  1 Comment
dpb
dpb on 6 Mar 2021
Edited: dpb on 6 Mar 2021
See <timetable.synchronize>. Also look at the "See Also" section for more on the general problem of cleaning up time series data. In short, don't try to physically align the data by location by hand; read in the data available and work on it in memory with the tools provided by MATLAB.

Sign in to comment.

Answers (1)

Aashita Dutta
Aashita Dutta on 25 Jan 2022
As per my understanding, you are trying to read multiple tables and unable to align these tables due to empty cells in the matrix.
There are a couple of ways to resolve this issue. You can use the rmmissing’ function in Matlab that removes missing entries from the table.
T = readtable('Skomakerfjellet2016.xlsx','Range','A4:B4783');
T1 = rmmissing(T);
You can also use detectImportOptions function that create import options based on file content with MissingRuleproperty to manage missing data.
opts = detectImportOptions(' Skomakerfjellet2016.xlsx ');
opts.MissingRule = 'omitrow';

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!