MATLAB Answers

0

Programmatically capturing screenshots of Simulink blocks and dialogs

Asked by Carl Banks on 1 Aug 2018
Latest activity Answered by David
on 9 Apr 2019
This is a shot in the dark, but does anyone know of a convenient built-in way to programmatically create screen captures of Simulink blocks and dialogs? This is for documentation purposes. We'd like to show an image of the block and the dialog in the documents but we don't want to manually screencap the block and dialog of upwards of a hundred blocks.

  2 Comments

You can import java packages into MATLAB, one of them (java.awt.* ??) includes the ability to take screenshots. I'm assuming there's an open or edit equivalent to launch each block, then use the java to capture screen.
I ended up doing this, and using some functions from image processing toolbox to help crop the screenshots. Thanks for the suggestions. If you repost this as an answer I'll accept it (if you care about that kind of thing).

Sign in to comment.

Products

3 Answers

Answer by Greg
on 10 Oct 2018
 Accepted Answer

You can import java packages into MATLAB, one of them (java.awt.* ??) includes the ability to take screenshots. I'm assuming there's an open or edit equivalent to launch each block, then use the java to capture screen.

  0 Comments

Sign in to comment.


Answer by Fangjun Jiang on 1 Aug 2018

You might want to try Simulink "Web View". In the Simulink model, click menu File, Export model to, Web...
A html document is created. You can browse the hierarchy of the model just like in Simulink. Block dialog is not shown but block parameters are shown whenever you click a block. This is great for documentation purpose.
Alternatively, try menu File, Print, to a PDF file.

  0 Comments

Sign in to comment.


Answer by David
on 9 Apr 2019

Simulink has this built in:
% Open a model
f14
% Choose name of model to be screenshot
ModelName = 'f14'
% Save the screenshot to a file, named the model name...
print(['-s',ModelName],'-djpeg',[ModelName,'.jpg'])
You can choose: JPG, BMP, PNG etc
More here: print

  0 Comments

Sign in to comment.