save a single subplot from a .mat file that contains 2x1 subplots

2 Ansichten (letzte 30 Tage)
I have a saved .mat figure with two subplots as a 2x1. I have no access to the code. What is the fastest way to get the 1x1 subplot and plot it on a new figure by it self.
My temp solution...
I ended up selecting the "pointer/mouse" icon and just deleted the second subplot. Resized the desired plot and then saved it.
Can someone provide a coded solution?

Akzeptierte Antwort

Adam Danz
Adam Danz am 15 Jul. 2019
Bearbeitet: Adam Danz am 15 Jul. 2019
There's nothing wrong with your solution of deleting the unneccessary subplot and resizing the desired one. If you need to do this with many subplots, you can write a short function or script like this
% get handles to axes of current figure
axh = findobj(gcf,'Type','axes');
% Delete the 2nd axes
delete(axh(2))
% expand the size of 1st axes
axh(1).Units = 'Normalize'; % I prefer working in normal units
axh(1).Position = [.1,.1,.8,.8];
An alternative would be to merely copy the content of the desired subplot onto a new axis within a new figure using copyobj()
% Create new figure and new axes
figure();
newax = cla();
% Copy the content (children) of 1st axes into the new axes.
copyobj(axh(1).Children,newax)

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by