Show image of variable Simulink model in Matlab GUI

I have created a GUI with GUIDE to run simulink models, change parameters, etc. I would like an image of the flowsheet to appear in one of the GUI's tabs. For the default flowsheet, I have an image (screenshot) of it and use imshow in the axes CreateFcn. However, as the users can modify the flowsheet or create new ones, I won't have an image for each of them created. Do you know if is there any function to generate an image of the flowsheet? I read that it is not possible to integrate the simulink editor within the Matlab GUI, is that ok?
Thank you very much in advance.

 採用された回答

TAB
TAB 2013 年 2 月 22 日
編集済み: TAB 2013 年 2 月 22 日

1 投票

If you want to display the image of simulink model in your GUI then you can follow the below steps
  • Suppose your model is MyModel.mdl and you want to display image or root level of model.
  • Open the model
open_system('MyModel')
  • Save snapshot of your model in an image file & close model
print -sMyModel ModelImg.jpg -djpeg
close_system('MyModel')
  • Read & display generated image file in GUI
ImgData = imread('ModelImg.jpg')

5 件のコメント

Cristina
Cristina 2013 年 2 月 25 日
Thank you very much. However, the quality of the image is not very good. Do you know how could I improve it? (I rotated it using rot90).
A flowsheet is the flowchart in a process (inputs and outputs streams, processes, etc.)
TAB
TAB 2013 年 2 月 25 日
編集済み: TAB 2013 年 2 月 25 日
For good quality image, you can save the it in 24 bit BMP format using
print -sMyModel ModelImg.bmp -dbmp
close_system('MyModel')
JPEG is compressed image format which gives image in smaller file size with reduced quality.
Please accept answer if it helped.
Cristina
Cristina 2013 年 2 月 25 日
The result is the same for both formats. Any other options?
TAB
TAB 2013 年 2 月 25 日
I don't know why. Try
print -sMyModel ModelImg.bmp -dbmp16m
Cristina
Cristina 2013 年 2 月 25 日
It makes the image slightly bigger but of similar or even worse quality

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInteractive Model Editing についてさらに検索

質問済み:

2013 年 2 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by