How to make a reference to multiple subelements of a cell without for loop (to create a plot)

K
kellysmith9 · Sep 7, 2020 · 1.9K views
Question
lets say I have a axb cell , each cell contains a 1xn double I want to make a plot like this plot({1,:}(1,end)) , i.e. for the first row of this cell I want to plot each cells last datapoint. I know this syntax doesn't work for cells, and it gives me the error "Incorrect cell or structure reference involving "end". Most likely cause is a reference to multiple elements of a cell or structure followed by additional subscript or structure references." But how would you do this seemingly simple task?
Expert Answer
Profile picture of Neeta Dsouza
Neeta Dsouza PhD Expert
Answered Aug 26, 2026
 your_vals = cellfun(@(x) x(end),your_cell)
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!