MATLAB: How to import an image of the Simulink model directly to a MATLAB variable

imageMATLABmodelsimulink

I have a Simulink model, and I would like to store the image of that model in a MATLAB variable. I would prefer to do this directly without creating extraneous image files.

Best Answer

The ability to directly import the image of a Simulink model to a MATLAB variable is not available in MATLAB.
To work around this issue, the image can be written to a file and subsequently read into MATLAB using an example like the following:
% Select the Simulink model to bring it into focus.Then, execute the following:
print -smodelname -djpeg myscreenshot.jpg
A=imread('myscreenshot.jpg');
Related Question