Search code examples
matlabmatrixplotsubplotimshow

Get matrix from plot and subplot in Matlab


I already had some figure that I saved before, Like this:

enter image description here

Now after some days, I need the original size of these images for copy these in my paper. I want to extract the main matrix of these three image for save these again with imwrite function.

I searched this problem on the internet but the people says I have to use getframe and frame2im functions. But how? I want the original matrix. Can anyone tell me how to extract the main matrix from the figured image in matlab??


Solution

  • Try using the following code:

    imgs = findobj(gcf,'Type','image');
    images = cell(1,numel(imgs));
    for i = 1:numel(imgs)
        images = get(imgs(i),'CData');
    end
    

    The image matrices should now be stored in the separate cells of images.