How do I get multiple images in Simulink mask editor (Icon Drawing Commands)

6 ビュー (過去 30 日間)
Hi,
I am kind of new to Simulink and I was wondering how I could get different images to show on block (mask) depending on what block parameter is selected. I have different images in a folder and depending on what aircraft the user choses in the drop down menu in the block parameters, I would like to display the corresponding image on the mask. I looked up this in simulink tutorials and they seem to always mention "image", but never "images". Is what I'm trying to do even possible? And if it isn't out of the box, is there a work-around I could use? I'll attach images to help understand my problem.
Thanks,
Daniel
mask image error.png

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 7 月 19 日
Hi Daniel,
Your task is absolutely doable. First, you'd need to create three variables (as I see in your task you have four options to choose from, right?), e.g. as shown in the following mask's screenshot:
MASK_play.jpeg
and insert the following code in your mask's Icon & Ports tab (icon drawing commands) e.g.:
Image_Opt= get_param(gcb, 'Image_Select');
if strcmp(Image_Opt,'Single Seat')
image('Airbus eFan.png');
elseif strcmp(Image_Opt,'Double Seat')
image('Magnus eFusion.png');
elseif strcmp(Image_Opt,'Magnus')
image('Magnus eFusion.png');
else
image('figuresasbSkyHogg.png');
end
make sure that you have all images, to be displayed in the mask, placed in your current directory. In case, you need, I have attached my 'dummy' subsystem - MASK_play.slx file.
Good luck.
  1 件のコメント
Daniel Longworth
Daniel Longworth 2019 年 7 月 22 日
with a little bit of tinkering it worked out!
Thanks for the help!

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

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2019 年 7 月 19 日
You are on the righ track to what you want to achieve.
The error is related to something else.
For example, 'abc'=='abc ' would cause "Matrix dimensions must agree" error.
Use isequal() or strcmp() to compare two strings.

カテゴリ

Help Center および File ExchangeString についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by