How to extract last element from the lists
Mostrar comentarios más antiguos
Suppose if my List has
list = {[1,2],2,[],[1,2,3]}
eg:
list{1} = [1,2] = %% print last element ==>> 2 list{2} = 2 list{3} = [] list{4} = [1,2,3] ==> 3 new_list = {2,2,[],3}
I need to extract last element from each list{i} Output should be like
new_list = {2,2,0,3}
4 comentarios
dpb
el 29 de Abr. de 2018
For what definition of nth element, pray tell? You have vectors of numel() = 2,1,0,3 for the cells and the ordinal position of your proposed solution is 1,1,[],3 which is, if anything, consistent in there is no consistency observable as to which is to be recalled (other than the third with no alternative available).
Aswin Sandirakumaran
el 29 de Abr. de 2018
dpb
el 29 de Abr. de 2018
That's not what the original said; no fair changing the problem and then acting like didn't... :)
Aswin Sandirakumaran
el 30 de Abr. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Graphics Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!