How can I loop/index through a table inside a table to generate plots? I'd like to store the plots back into the table.
Show older comments
I've built a table (Named: Book1) in MATLAB that is 83x5, 83 rows and 5 columns.
Each row in the 5th column has a table with dimension Nx3, N rows and 3 columns.
- I'd like to index/loop into each table in the 5th column and plot the 1st-column vs. 3rd-column
-During looping/indexing, I'd like to create a 6th column(Named: Plot) in the table (Named: Book1) that will store each genreated plot.
After looping//indexing, I'd like to view the plot by simply clicking Plot1,Plot2,Plot3,etc... An example of the completed output is below:

This is possible as I've seen it before, unsure how to approach / carry out the request.
Accepted Answer
More Answers (1)
After running the code, you can access the generated plots by simply clicking on the corresponding plot in the Book1 table's 6th column.
That's true as long as the figure window remains open. That code does not somehow "embed" the figure into the table array. Once the figure window gets closed, the handle becomes a handle to a deleted figure.
t = table((1:5).', gobjects(5, 1), 'VariableNames', ["data", "figures"])
x = 1:10;
for r = 1:height(t)
t.figures(r) = figure;
ax = axes('Parent', t.figures(r));
plot(x, x.^r, 'Parent', ax)
end
t{3, 'figures'}
close all
t{3, 'figures'}
Also, creating and leaving open 83 separate figure windows is likely to make it difficult to find a specific one you want to look at, and could consume a good amount of memory especially if the data you're plotting is large. You haven't stated what values of N you're working with.
What is your end goal in creating and storing the figures in the table? We may be able to suggest a more robust and/or more efficient way to solve the underlying problem you're trying to solve without opening nearly 100 figures.
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!