how can I extract first number of cell?

4 次查看(过去 30 天)
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

采纳的回答

C.J. Harris
C.J. Harris 2017-6-16
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 个)

skysky2000
skysky2000 2017-6-16
That amazing Harris . thanks alot

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by