How to extract last element from the lists
Show older comments
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 Comments
dpb
on 29 Apr 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
on 29 Apr 2018
dpb
on 29 Apr 2018
That's not what the original said; no fair changing the problem and then acting like didn't... :)
Aswin Sandirakumaran
on 30 Apr 2018
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!