how to display both a text and a userInput on mask using system object?

2 Ansichten (letzte 30 Tage)
Wilfried
Wilfried am 28 Mär. 2025
Beantwortet: Walter Roberson am 28 Mär. 2025
I am trying to display both a text and image on simulink block using system object and matlab system. The code below help me display both an image and a text. However, I would like to display a portion of the text that changes based on some actions performed by the user.
maskDisplay = [ ...
'image(''logo1.png'');' ... % Show an image
'disp(''My Text'');' % Display some text in center.
];
Goal: For example:
disp(''My text'' + userInput);
where userInput is a variable received from the user; however doing it this way does not work. I replaced the + with a comma, and it still does not work. How can I achieve that?

Antworten (2)

Image Analyst
Image Analyst am 28 Mär. 2025
Maybe try using sprintf with the names of your variables to create a string and then combine into a cell array of strings of different lengths?
string1 = sprintf('image("%s");', yourFileName) % Show an image
string2 = sprintf('disp("%s");', myText); % Display some text in center.
maskDisplay = {string1, string2}
  3 Kommentare
Image Analyst
Image Analyst am 28 Mär. 2025
Sorry - I don't have Simulink so I can't help further.
Wilfried
Wilfried am 28 Mär. 2025
No problem. Thank you so much for trying.

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 28 Mär. 2025
maskDisplay = [ ...
'image(''logo1.png'');' ... % Show an image
'disp("My Text', UserInput, '"');'
];

Kategorien

Mehr zu Create System Objects finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by