How to parse variable directly to mask workspace?
4 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Jiang Xin
2014-8-11
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);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!