Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Set Output Complexity

This example shows how to specify whether a System object™ output is complex or real using the isOutputComplexImpl method. Use this method when Simulink® cannot infer the output complexity from the inputs during model compilation.

Subclass from both the matlab.System base class and the Propagates mixin class.

 classdef CounterReset < matlab.System & ...
     matlab.system.mixin.Propagates

Use the isOutputComplexImpl method to specify that the output is real.

methods (Access = protected)
   function cplxout = isOutputComplexImpl(~)
      cplxout = false;
   end
end

View the method in the complete class definition file.

classdef CounterReset < matlab.System & matlab.system.mixin.Propagates
   % CounterReset Count values above a threshold
    
   properties
      Threshold = 1
   end
  
   properties (DiscreteState)
      Count
   end
  
   methods (Access = protected)
      function setupImpl(obj)
         obj.Count = 0;
      end
    
      function resetImpl(obj)
         obj.Count = 0;
      end
    
      function y = stepImpl(obj,u1,u2)
         % Add to count if u1 is above threshold
         % Reset if u2 is true
         if (u2)
            obj.Count = 0;
         elseif (u1 > obj.Threshold)
            obj.Count = obj.Count + 1;
         end
         y = obj.Count;
      end
    
      function [sz,dt,cp] = getDiscreteStateSpecificationImpl(~,name)
         if strcmp(name,'Count')
            sz = [1 1];
            dt = 'double';
            cp = false;
         else
            error(['Error: Incorrect State Name: ', name.']);
         end
      end
      function dataout = getOutputDataTypeImpl(~)
         dataout = 'double';
      end
      function sizeout = getOutputSizeImpl(~)
         sizeout = [1 1];
      end
      function cplxout = isOutputComplexImpl(~)
         cplxout = false;
      end
      function fixedout = isOutputFixedSizeImpl(~)
         fixedout = true;
      end
   end
end

See Also

|

More About

Was this topic helpful?