getting data types of table
Show older comments
I want to compare data types of each column of a table against a cell array of column header-data type pairs, with the end goal of replacing columns with non-matching data types with the correct ones.
What I have managed so far is a loop that creates another cell array of header-data type pairs. What I need now is a way to compare this array to the 'checklist' array, returning which columns have non-matching data types. There is no guarantee of the table having the same columns or being on the same order as the array it is checked against. I tried ismember() but it just returns a 2xn array of 1s, even for tables that shouldn't match. I think I need to define key/value pairs somehow.
Any suggestions on how to do this, or other methods entirely, are more than welcome!
1 Comment
dpb
on 1 Jan 2024
Agree, this should be a metadata property of the table and thus directly accessible.
Accepted Answer
More Answers (1)
Geoff Hayes
on 27 Sep 2016
>> x = 42;
>> class(x)
ans =
double
This function may be useful in determining the data type of each object in your table.
1 Comment
Giuseppe Degan Di Dieco
on 30 Nov 2021
Thank you Geoff!
The suggested command works also with table variables.
Best!
Categories
Find more on Data Type Identification in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!