Allora....
ho iniziato a lavorare studiando dalla base gli m-file s-function.
Sto per il momento facendo una funzione cn 2 in e 2 out nella ql devo verificare che se:
1. in1=0 & in2=0 > out1=0 e out2=0
2. in1=1 & in2=0 > out1=1 e out2=1
3. in1=0 & in2=1 > out1=0 e out2=0
4. in1=1 & in2=1 > out1=0 e out2=0
per realizzare cio' ho realizzato la seguente level 2 m-file s-function.....che mi da l'errore seguente:
Level-2 M-file S-function 'nome' does not exist.
il codice che ho utilizzato e' il seguente...spero in un aiuto di qlcn piu' brv di me...
function msfcn_fase(block)
%% qst msfcn_fase rappresenta la fase in un sfc
%% abbiamo 2 ingressi e 2 uscite(in1,in2,out1,out2)
%% 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
function setup(block)
block.NumDialogPrms = 0;
% Register number of ports abbiamo un in e un out
block.NumInputPorts = 2;
block.NumOutputPorts = 2;
% Setup port properties to be inherited or dynamic
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
block.InputPort(1).DatatypeID = 0; % double
block.InputPort(1).Complexity = 'Real';
block.InputPort(1).Dimensions = 1;
block.InputPort(1).DirectFeedthrough = true;
block.InputPort(1).SamplingMode = 0;
block.InputPort(2).DatatypeID = 0; % double
block.InputPort(2).Complexity = 'Real';
block.InputPort(2).Dimensions = 1;
block.InputPort(2).DirectFeedthrough = true;
block.InputPort(2).SamplingMode = 0;
block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(1).Dimensions = 1;
block.OutputPort(1).SamplingMode = 0;
block.OutputPort(2).DatatypeID = 0; % double
block.OutputPort(2).Complexity = 'Real';
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).SamplingMode = 0;
% Register sample times
% [-1, 0] : Inherited sample time
block.SampleTimes = [-1 0];
%% -----------------------------------------------------------------
%% Options
%% -----------------------------------------------------------------
% Specify if Accelerator should use TLC or call back into
% M-file
block.SetAccelRunOnTLC(true);
%% Register methods
block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
block.RegBlockMethod('InitializeConditions', @InitConditions);
block.RegBlockMethod('Outputs', @Output);
%endfunction
block.NumDworks = 2;
block.Dwork(1).Name = 'set';
block.Dwork(1).Dimensions = 1;
block.Dwork(1).DatatypeID = 0;
block.Dwork(1).Complexity = 'Real';
block.Dwork(2).Name = 'reset';
block.Dwork(2).Dimensions = 1;
block.Dwork(2).DatatypeID = 0;
block.Dwork(2).Complexity = 'Real';
%endfunction
function InitConditions(block)
%% Initialize Dwork
block.Dwork(1).Data = 0;
block.Dwork(2).Data = 0;
%endfunction
function Output(block)
A = block.InputPort(1).Data ;
B = block.InputPort(2).Data;
if (B=1)
block.Dwork(1).Data = 0;
block.Dwork(2).Data = 0;
end
if (B=0)
if (A=1)
block.Dwork(1).Data = 1;
block.Dwork(2).Data = 1;
else
block.Dwork(1).Data = 0;
block.Dwork(2).Data = 0;
end
block.OutputPort(1).Data=block.Dwork(1).Data;
block.OutputPort(2).Data=block.Dwork(2).Data;
%endfunction
grazie a tutti