how can I extract first number of cell?

2 vues (au cours des 30 derniers jours)
skysky2000
skysky2000 le 16 Juin 2017
Commenté : skysky2000 le 4 Juil 2017
Dear All, I am facing problem that I have cell a ={[8,21,291,94,455,241,227,36,130] [15,248,455,241,227,36,130] [21,291,94,455,241,227,36,130] [36,130]} the question is: 1- how can I extract first number of each cell and put it as vector, expect answer is : c= [8 15 21 36];
2- how can I delete the first element of each cell and make others as vector without first element, expect answer is: d=[21,291,94,455,241,227,36,130,248,455,241,227,36,130,291,94,455,241,227,36,130,130]
Hope can you help me, Thanks alot

Réponse acceptée

C.J. Harris
C.J. Harris le 16 Juin 2017
a ={[8,21,291,94,455,241,227,36,130] [15,248,455,241,227,36,130] [21,291,94,455,241,227,36,130] [36,130]};
Question 1:
c = cell2mat(cellfun(@(x)(x(1)), a, 'UniformOutput', false));
Question 2:
d = cell2mat(cellfun(@(x)(x(2:end)), a, 'UniformOutput', false));
  1 commentaire
skysky2000
skysky2000 le 4 Juil 2017
thanks alot sorted it out

Connectez-vous pour commenter.

Plus de réponses (1)

skysky2000
skysky2000 le 16 Juin 2017
That amazing Harris . thanks alot

Catégories

En savoir plus sur Just for fun 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