Jack2007
Jack2007

Reputation: 59

Change a cell array into a matrix in matlab

everyone, I have a cell array in MATLAB:

'AA->AA'    [ 9]    [1.8036]
'AA->AC'    [ 6]    [1.2024]
'AA->AG'    [13]    [2.6052]
'AA->AT'    [ 9]    [1.8036]

I want to change it into a matrix with the row names are 'AA->AA','AA->AC'.....ect,I tried cell2mat and it reminded me: All contents of the input cell array must be of the same data type. so anyone give me an idea.

Thanks.

Upvotes: 0

Views: 145

Answers (1)

Shai
Shai

Reputation: 114976

Use containers.Map:

myData = containers.Map();
for ii=1:size( myCell, 1 )
    myData( myCell{ii,1} ) = [myCell{ii,:}];
end

Upvotes: 1

Related Questions