cell to double with reduced array size

5 visualizzazioni (ultimi 30 giorni)
ali mujtaba
ali mujtaba il 24 Nov 2014
Modificato: Star Strider il 24 Nov 2014
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

Risposte (1)

Star Strider
Star Strider il 24 Nov 2014
Modificato: Star Strider il 24 Nov 2014
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

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by