MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

end
end
end


Run this System object with one, two, and three inputs.


addObj = AddTogether;
addObj(2)


ans =


2


addObj(2,3)


ans =


5


addObj(2,3,4)


ans =


9


Control the Number of Inputs and Outputs with a Property


This example shows how to write a System object that allows changes to the number of
inputs and outputs before running the object. Use this method when your System object
will be included in Simulink:



  • Add a nontunable property NumInputs to control the number of inputs.

  • Implement the associated getNumInputsImpl method to specify the number of
    inputs.


Full Class Definition


classdef AddTogether2 < matlab.System


Change the Number of Inputs
Free download pdf