Effacer les filtres
Effacer les filtres

How to use num2cell?

1 vue (au cours des 30 derniers jours)
Dixie Cross
Dixie Cross le 8 Avr 2016
Modifié(e) : Matt J le 8 Avr 2016
I'm trying to create a cell array. I'm using the below coding for the array but the third column contains data, which needs to be converted to a separate array to be seen. I'm not sure what I'm doing wrong.
production={'Ran k' 'Country/Region' [2014, 2013, 2012, 2011, 2010];
'2','China' [23722890,22116825,19271808,18418876,18264761];
'2','European Union',[16976883,16240989,16240476,17707126,17107350];
'3','United States',[11660699,11066432,10335765,8661535,7743093];
'4','Japan',[9774558,9630181,9943077,8398630,9628920];
'5','Germany',[5907548,5718222,5649260,6146948,5905985];
'6','South Korea',[4524932,4521429,4561766,4657094,4271741];
'7','India',[3365306,3054849,3001814,2681050,2342282];
'8','Brazil',[3364890,3712380,3402508,3407861,3381728];
'9','Spain',[2402978,2163338,1979179,2373329,2387900];
'10','Canada',[2393890,2379806,2463364,2135121,2068189]}
c=num2cell(production{:,3})

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 8 Avr 2016
c=num2cell(cell2mat(production(:,3)))

Plus de réponses (1)

Stalin Samuel
Stalin Samuel le 8 Avr 2016
third column data is already in cell.So simply use the below
c = production(:,3)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by