How to parse variable directly to mask workspace?
조회 수: 8 (최근 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!