cell to double with reduced array size

5 次查看(过去 30 天)
Hi I want to convert cell array to double. I am using cell2mat but again I am getting matrix of 34490x20. I want 34490x2 double. otherwise there is no purpose to use cell2mat. please help me in this regard. thnx

回答(1 个)

Star Strider
Star Strider 2014-11-24
编辑:Star Strider 2014-11-24
You can do it without cell2mat. If you want to get specific columns, use one of these assignment options to get your (34490x2) double array:
C = {randi(10,30,20)}; % Create Data (Cell Array)
D = C{:}(:,1:2); % Get Columns 1 & 2 As Double Array
D = C{:}(:,[10 15]); % Alternative: Get Any 2 Columns (Here 10 & 15)
Alternatively, if you have more than one array in your cell:
C = {randi(10,30,20) randi(10,30,20)}; % Create Data (Cell Array)
D = C{1}(:,1:2); % Get Colimns 1 & 2 Of Array 1 As Double Array
D = C{2}(:,[10 15]); % Alternative: Get Any 2 Columns Of Array 2

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by