Change only one port label without having to rewrite all the mask

2 次查看(过去 30 天)
Hello everyone,
I need some help to find a way to change the port label of only one input of a masked system and don't have to rewrite all the maskdisplay.
my boss/teacher want that I design a masked system which will be capable to change dynamically the color of the input port based on the input data choosen by user. My usual way to do that it is by this instruction:
set_param(gcb, 'MaskDisplay', '.....')
which is fair for a number of limited dynamic input port, but for more then 4 it is impossible, because I need to consider all the possible combinations for the input ports. for example for 5 input ports, which can be either red or green I have to write 64 if conditions
red red red red red red red red red green red red red green red red red red green green .........................
set_param(gcb, 'MaskDisplay', 'disp(''ITG_R''), color(''black''), port_label(''input'',1,''\bf{\equiv> In}'',''texmode'',''on''), color(''red''), port_label(''input'',2,''\bf{\equiv> Ti}'',''texmode'', ''on''), color(''black''), port_label(''input'',3,''\bf{\rightarrow Tc}'',''texmode'', ''on''), color(''black''), port_label(''input'',4,''\bf{\rightarrow Tv}'',''texmode'', ''on''), color(''black''), port_label(''input'',5,''\bf{\rightarrow Hlt}'',''texmode'', ''on''), color(''black''), port_label(''input'',6,''\bf{\rightarrow Ul}'',''texmode'', ''on''), color(''black''), port_label(''input'',7,''\bf{\rightarrow Ll}'',''texmode'', ''on''), color(''green''), port_label(''input'',8,''\bf{\rightarrow Per}'',''texmode'', ''on''), color(''red'') port_label(''output'',1,''\bf{Re \equiv>}'',''texmode'', ''on''), color(''black''), port_label(''output'',2,''\bf{Ula \rightarrow}'',''texmode'', ''on''), color(''black''), port_label(''output'',3,''\bf{Lla \rightarrow}'',''texmode'', ''on''), color(''black''), port_label(''output'',4,''\bf{Err \rightarrow}'',''texmode'', ''on'') ')
So to modify just a label of a port I have to rewrite all the maskdisplay or there is another way
thanks in advance

采纳的回答

grapevine
grapevine 2012-3-9
I found a way
set_param(gcb, 'MaskDisplay',strrep(get_param(gcb, 'MaskDisplay'), 'color(''black''), port_label(''output'',1,''=','color(''red''), port_label(''output'',1,''='))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Classification Ensembles 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by