Hi,
I am trying to write a state machine, I am getting the error
??? Input argument "block" is undefined.
Error in ==> equalstestb at 19
setup(block);
??? Reference to non-existent field 'SetPreCompInpPortInfoToDynamic'.
The attached is the start of my m-file, what is the usuall cause of this error?
Thanks
function equalstestb(block)
%equalstestb A template for a Leve-2 M-file S-function
% The M-file S-function is written as a MATLAB function with the
% same name as the S-function. Replace 'equalstestb' with the
% name of your S-function.
%
% It should be noted that the M-file S-function is very similar
% to Level-2 C-Mex S-functions. You should be able to get more
% information for each of the block methods by referring to the
% documentation for C-Mex S-functions.
%
% Copyright 2003-2007 The MathWorks, Inc.
%%
%% The setup method is used to setup the basic attributes of the
%% S-function such as ports, parameters, etc. Do not add any other
%% calls to the main body of the function.
%%
setup(block);
%endfunction
%% Function: setup ===================================================
%% Abstract:
%% Set up the S-function block's basic characteristics such as:
%% - Input ports
%% - Output ports
%% - Dialog parameters
%% - Options
%%
%% Required : Yes
%% C-Mex counterpart: mdlInitializeSizes
%%
%%
function setup(block)
% Register number of ports
block.NumInputPorts = 2;
block.NumOutputPorts = 3;
% Setup port properties to be inherited or dynamic
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
% Override input port properties
block.InputPort(1).Dimensions = 1;
block.InputPort(1).DatatypeID = 0; % double
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).DirectFeedthrough = true;
block.InputPort(2).Dimensions = 1; % input out of spec
block.InputPort(2).DatatypeID = 0; % double
block.InputPort(2).Complexity = 'Boolean';
block.InputPort(2).DirectFeedthrough = true;
% Override output port properties
block.OutputPort(1).Dimensions = 1;
block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 0; % double
block.OutputPort(2).Complexity = 'Real';
block.OutputPort(3).Dimensions = 1;
block.OutputPort(3).DatatypeID = 0; % double
block.OutputPort(3).Complexity = 'Integer';
% Register parameters
block.NumDialogPrms = 0;
% Register sample times
% [0 offset] : Continuous sample time
% [positive_num offset] : Discrete sample time
%
% [-1, 0] : Inherited sample time
% [-2, 0] : Variable sample time
block.SampleTimes = [-1 0];
% Specify the block simStateComliance. The allowed values are:
% 'UnknownSimState', < The default setting; warn and assume DefaultSimState
% 'DefaultSimState', < Same sim state as a built-in block
% 'HasNoSimState', < No sim state
% 'CustomSimState', < Has GetSimState and SetSimState methods
% 'DisallowSimState' < Error out when saving or restoring the model sim state
block.SimStateCompliance = 'DefaultSimState';
%% -----------------------------------------------------------------
%% The M-file S-function uses an internal registry for all
%% block methods. You should register all relevant methods
%% (optional and required) as illustrated below. You may choose
%% any suitable name for the methods and implement these methods
%% as local functions within the same file. See comments
%% provided for each function for more information.
%% -----------------------------------------------------------------
block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
block.RegBlockMethod('InitializeConditions', @InitializeConditions);
block.RegBlockMethod('Start', @Start);
block.RegBlockMethod('Outputs', @Outputs); % Required
block.RegBlockMethod('Update', @Update);
block.RegBlockMethod('Derivatives', @Derivatives);
block.RegBlockMethod('Terminate', @Terminate); % Required
block.InputPort(1).SamplingMode = 'Sample';
block.InputPort(2).SamplingMode = 'Sample';
block.OutputPort(1).SamplingMode = 'Sample';
block.OutputPort(2).SamplingMode = 'Sample';
block.OutputPort(3).SamplingMode = 'Sample';
%block.RegBlockMethod('SetInputPortSamplingMode', @SetInpPortSamplingMode);
%end setup
|
|
0
|
|
|
|
Reply
|
James
|
4/26/2010 3:56:04 PM |
|
On Monday, April 26, 2010 11:56:04 AM UTC-4, James Salisbury wrote:
> Hi,
>
> I am trying to write a state machine, I am getting the error
> ??? Input argument "block" is undefined.
> Error in ==> equalstestb at 19
> setup(block);
> ??? Reference to non-existent field 'SetPreCompInpPortInfoToDynamic'.
>
> The attached is the start of my m-file, what is the usuall cause of this error?
>
> Thanks
>
>
>
> function equalstestb(block)
> %equalstestb A template for a Leve-2 M-file S-function
> % The M-file S-function is written as a MATLAB function with the
> % same name as the S-function. Replace 'equalstestb' with the
> % name of your S-function.
> %
> % It should be noted that the M-file S-function is very similar
> % to Level-2 C-Mex S-functions. You should be able to get more
> % information for each of the block methods by referring to the
> % documentation for C-Mex S-functions.
> %
> % Copyright 2003-2007 The MathWorks, Inc.
>
> %%
> %% The setup method is used to setup the basic attributes of the
> %% S-function such as ports, parameters, etc. Do not add any other
> %% calls to the main body of the function.
> %%
> setup(block);
>
> %endfunction
>
> %% Function: setup ===================================================
> %% Abstract:
> %% Set up the S-function block's basic characteristics such as:
> %% - Input ports
> %% - Output ports
> %% - Dialog parameters
> %% - Options
> %%
> %% Required : Yes
> %% C-Mex counterpart: mdlInitializeSizes
> %%
> %%
> function setup(block)
>
> % Register number of ports
> block.NumInputPorts = 2;
> block.NumOutputPorts = 3;
>
> % Setup port properties to be inherited or dynamic
> block.SetPreCompInpPortInfoToDynamic;
> block.SetPreCompOutPortInfoToDynamic;
>
>
>
> % Override input port properties
> block.InputPort(1).Dimensions = 1;
> block.InputPort(1).DatatypeID = 0; % double
> block.InputPort(1).Complexity = 'Real';
> block.InputPort(1).DirectFeedthrough = true;
>
> block.InputPort(2).Dimensions = 1; % input out of spec
> block.InputPort(2).DatatypeID = 0; % double
> block.InputPort(2).Complexity = 'Boolean';
> block.InputPort(2).DirectFeedthrough = true;
>
> % Override output port properties
> block.OutputPort(1).Dimensions = 1;
> block.OutputPort(1).DatatypeID = 0; % double
> block.OutputPort(1).Complexity = 'Real';
> block.OutputPort(2).Dimensions = 1;
> block.OutputPort(2).DatatypeID = 0; % double
> block.OutputPort(2).Complexity = 'Real';
> block.OutputPort(3).Dimensions = 1;
> block.OutputPort(3).DatatypeID = 0; % double
> block.OutputPort(3).Complexity = 'Integer';
>
>
> % Register parameters
> block.NumDialogPrms = 0;
>
> % Register sample times
> % [0 offset] : Continuous sample time
> % [positive_num offset] : Discrete sample time
> %
> % [-1, 0] : Inherited sample time
> % [-2, 0] : Variable sample time
> block.SampleTimes = [-1 0];
>
> % Specify the block simStateComliance. The allowed values are:
> % 'UnknownSimState', < The default setting; warn and assume DefaultSimState
> % 'DefaultSimState', < Same sim state as a built-in block
> % 'HasNoSimState', < No sim state
> % 'CustomSimState', < Has GetSimState and SetSimState methods
> % 'DisallowSimState' < Error out when saving or restoring the model sim state
> block.SimStateCompliance = 'DefaultSimState';
>
> %% -----------------------------------------------------------------
> %% The M-file S-function uses an internal registry for all
> %% block methods. You should register all relevant methods
> %% (optional and required) as illustrated below. You may choose
> %% any suitable name for the methods and implement these methods
> %% as local functions within the same file. See comments
> %% provided for each function for more information.
> %% -----------------------------------------------------------------
>
> block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
> block.RegBlockMethod('InitializeConditions', @InitializeConditions);
> block.RegBlockMethod('Start', @Start);
> block.RegBlockMethod('Outputs', @Outputs); % Required
> block.RegBlockMethod('Update', @Update);
> block.RegBlockMethod('Derivatives', @Derivatives);
> block.RegBlockMethod('Terminate', @Terminate); % Required
> block.InputPort(1).SamplingMode = 'Sample';
> block.InputPort(2).SamplingMode = 'Sample';
>
>
> block.OutputPort(1).SamplingMode = 'Sample';
> block.OutputPort(2).SamplingMode = 'Sample';
> block.OutputPort(3).SamplingMode = 'Sample';
>
> %block.RegBlockMethod('SetInputPortSamplingMode', @SetInpPortSamplingMode);
>
> %end setup
I got similar type of error while trying to run lvl 2 m-file s function.
??? Input argument "block" is undefined.
Error in ==> svpwm_states at 2
setup(block);
Have you found the solution?!
|
|
0
|
|
|
|
Reply
|
bhumiin (1)
|
7/11/2012 11:05:13 PM
|
|
|
1 Replies
645 Views
(page loaded in 0.083 seconds)
|