Axel
Axel

Reputation: 1475

How to obtain rows of an incomplete Matlab table?

After getting answers to this question I realized that I do have a problem with importing data into Matlab but it has nothing to do with NaNs but rather with different data types stored in the table.

In the same example I used in the other question importing an Excel table

Excel table

using

measurementTable = readtable('MWE.xlsx','ReadVariableNames',false,'ReadRowNames',true);

leads to the Matlab table

Matlab table

As you can see the values in column 1 to 4 are of type cell while the values in column 5 are of type double. If I would now try to obtain a single row of the table by using

measurementTable{'DATE',:}

I get the error message:

Cannot concatenate the table variables 'Var5' and 'Var1', because their types are double and cell.

How can I tackle this problem?

Upvotes: 0

Views: 103

Answers (1)

matlabgui
matlabgui

Reputation: 5672

As you worked out the command you are using is failing due to Matlab trying to combine the cells and doubles to an array.

Since you have multiple data types you need to store your "row" in a cell array.

You can obtain a single row of mixed data by doing:

table2cell ( measurementTable('DATE',:) )

Upvotes: 0

Related Questions