0
votes

I'm trying to plot something in a cell array, so I'm trying to convert one of the columns to a matrix.

I pulled out the column from the cell array and tried to do cell2mat on it to turn it into a matrix. However, cell2mat seems to just turn it into one long character array.

site(:,4)'; % Pull out column 4 from the cell array
cell2mat(ans); % Attempt to convert the cell into a matrix

The first part of the code gives me: 10.4 10.1 7.9 8.2

The second part of the code gives me: 10.410.17.98.2

How can I make the cell into a matrix that I can use to plot a graph?

2

2 Answers

2
votes

It appears that your cell array contains strings, is that correct? In that case you don't use cell2mat, but str2double:

str2double(site(:,4).')

For example:

>> site = {'1',   '2',   '3',   '4';
           '1.1', '2.1', '3.1', '4.1'};
>> str2double(site(:,4).')
ans =
    4.0000    4.1000
0
votes

Assuming x is your abstract:

y = site(:,4)';

You can now make it a vector and plot it as such:

plot([y{:}])