Insufficient number of input parameters.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function calculate_gain_sfunc(block)
setup(block);
end
function setup(block)
% Register the number of ports
block.NumInputPorts = 3; % Q1, Q2, and F2(t)
block.NumOutputPorts = 2; % y1 and y2
% Set up the input and output ports
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;
block.InputPort(1).Dimensions = 1; % Q1
block.InputPort(2).Dimensions = 1; % Q2
block.InputPort(3).Dimensions = 1; % F2
block.OutputPort(1).Dimensions = 1; % y1
block.OutputPort(2).Dimensions = 1; % y2
% Register the parameters
block.NumDialogPrms = 9; % J1, L1, R1, AE, F1, J2, L2, R2
% Set the sample time
block.SampleTimes = [0 0];
% Specify the block simStateCompliance
block.SimStateCompliance = 'DefaultSimState';
% Register the methods
block.RegBlockMethod('Outputs', @Output); % Register the output method
end
function Output(block)
% Get the inputs
Q1 = block.InputPort(1).Data;
Q2 = block.InputPort(2).Data;
F2 = block.InputPort(3).Data;
% Get the parameters
J1 = block.DialogPrm(1).Data;
L1 = block.DialogPrm(2).Data;
R1 = block.DialogPrm(3).Data;
AE = block.DialogPrm(4).Data;
F1 = block.DialogPrm(5).Data;
J2 = block.DialogPrm(6).Data;
L2 = block.DialogPrm(7).Data;
R2 = block.DialogPrm(8).Data;
% Compute the gains
gain1 = J1 * L1 / (R1 * (AE - F1));
gain2 = J2 * L2 / (R2 * (F2 - AE));
% Compute the outputs
y1 = gain1 * Q1;
y2 = gain2 * Q2;
% Set the outputs
block.OutputPort(1).Data = y1;
block.OutputPort(2).Data = y2;
运行结果:
calculate_gain_sfunc
输入参数的数目不足。
出错 calculate_gain_sfunc (line 2)
setup(block);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!