필터 지우기
필터 지우기

Not Enough Input Arguments when using cm.addCustomMenuFcn

조회 수: 11 (최근 30일)
umichguy84
umichguy84 2017년 11월 7일
댓글: umichguy84 2017년 11월 24일
I'm trying to add some menu customizations. I'm starting with this Mathworks Example. However, it's not working. When running the code I get the following error.
_Not enough input arguments.
Error in simulinkMenuCustomisation (line 3) cm.addCustomMenuFcn('Simulink:ToolsMenu', @getMyMenuItems);__
function sl_customization(cm)
% Register custom menu function.
cm.addCustomMenuFcn('Simulink:ToolsMenu', @getMyMenuItems);
end
function schemaFcns = getMyMenuItems(callbackInfo)
schemaFcns = {@createBO};
end
function schema = createBO(callbackInfo)
schema = sl_action_schema;
schema.label = 'Align Inputs to Ports';
schema.statustip = 'Align Inputs to Ports';
schema.accelerator = 'Crtl+Alt+I';
schema.callback = @createBOcb;
end
function createBOcb(~)
blockH = find_system(gcbh);
disp(get(blockH,'Name'))
end

채택된 답변

Chris Dyer
Chris Dyer 2017년 11월 20일
Looks like this is due to attempting to run this script standalone.
The script requires the customization manager to be passed in as an argument to the sl_customization function (this is the missing argument).
This is done automatically when simulink starts (it will execute any sl_customization files it finds on the MATLAB path).
Keep in mind that if you are using simulink projects, simulink is started as soon as you open a project and before any project paths have been added to the MATLAB path. So saving your scripts within a project folder will likely not work and you will need to place it in a directory that is already on the MATLAB path.
I am not sure if there is a way to get the customization manager and pass it to this script manually after simulink has started.
  댓글 수: 1
umichguy84
umichguy84 2017년 11월 24일
Thanks for the tip. A couple other things I learned. The filename must be sl_customization.
Also, sl_refresh_customizations refreshes your simulink menu based on the latest save of your sl_customization.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by