Reputation: 13
When I import data from a database, I receive it as a cell. One row of the cell contains double values (such as 0.3421 0.5545 0.9199) and another row contains only int32 values (1 1 0). When I want to transform the whole cell with cell2mat, I get a mismatch error. If I use cell2mat on each row separately, I receive one matrix as double and one as int32. Is there a function being able to transform the whole cell to a matrix in double?
EDIT: I do not know beforehand which row is int32 and which is double, so it is not necessarily row 1 and 2. There are >50 rows
Upvotes: 1
Views: 743
Reputation: 1252
You can use cellfun to cast all data to doubles before using cell2mat:
a={int16(round(100*rand(100,1))), int32(round(100*rand(100,1)))}
b = cellfun(@double, a, 'uni', false);
cell2mat(b)
Upvotes: 1