当前位置: 动力学知识库 > 问答 > 编程问答 >

matlab - Add dialog parameter in mask from script

问题描述:

I'm using Matlab R2011a and I'm trying to add a dialog parameter to a mask from a command line. I saw in the R2013 simulink documentation that it is possible to do this in the new version :

p = Simulink.Mask.get(baseComponent);

p.addParameter('Type', 'popup', ...

'TypeOptions', {'Default values' 'Variable names' 'User defined'}, ...

'Prompt', 'Default values', ...

'Name', 'setDefault')

I'm unable to use these commands in R2011a. What command should I use to do the exact same thing in Matlab R2011a?

网友答案:

This is absolutely possible in older versions of Matlab, without using the object interface, instead you must assemble the parameter attributes and then use set_param. It needs to be done in a certain order:

set_param(gcb,'MaskPrompts',maskPrompt);
set_param(gcb,'MaskStyles',maskStyles);
set_param(gcb,'MaskTunableValues',maskTunVals);
set_param(gcb,'MaskCallbacks',maskCallbacks);
set_param(gcb,'MaskEnables',maskEnables);
set_param(gcb,'MaskVariables',maskVar);
set_param(gcb,'Maskvalues',maskvalue);

Some attributes can be a cell array, others must be a long string that specifies each value. You should be able to quickly discover which is which by doing a get_param on a block that currently has parameters. HTH!

分享给朋友:
您可能感兴趣的文章:
随机阅读: