How to parse variable directly to mask workspace?

4 views (last 30 days)
Hello I want to label the ports of my s-function. Actually I think I’m doing it on a complicated way: My s-function is in a library and gets a string (path) as a parameter. Dependent from this string and sets up different ports and outputs via mexPutVariable an array of strings to the base workspace. From here the array is parsed back to the mask of the s-function to label its ports. In the Dialog of the Path variable I use 2x set_param(gcs,'SimulationCommand','Update') Once for calling mdlInitilizeSizes to output the array, the 2nd time for labeling the ports. On this way the ports are changed and labeled correctly when I change the path. Is there a better way to do it? (R2011a) E.g. can I parse the array directly to the mask-workspace label the new/different ports? Would be glad about every hint!

Answers (1)

Jiang Xin
Jiang Xin on 11 Aug 2014
I'm not quite sure of your situation. What I suppose is: - use block callback StartFcn to parse the input, and store information in a Mask Workspace variable - modify the MaskDisplay command string, and maybe some necessary string replacement as per some customized pattern by yourself
raw_cmd=get_param(blk,'MaskDisplay');
full_cmd = regexprep(raw_cmd,...
'%{DYNAMIC_MASK_DRAWING_BEGIN}.*?%{DYNAMIC_MASK_DRAWING_END}',...
sprintf('%%{DYNAMIC_MASK_DRAWING_BEGIN}\n%s\n%%{DYNAMIC_MASK_DRAWING_END}',extra_maskdraw_cmd));
set_param(blk,'MaskDisplay',full_cmd);

Products

Community Treasure Hunt

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

Start Hunting!