Main Content

fixInput

Fix value of some inputs and delete them

Since R2024a

    Description

    Use fixInput to fix a nonzero value to inputs and discard them.

    For state-space models with offsets (ss, sparss, ltvss, and lpvss), using array indexing sys(:,J) discards all inputs not listed in J by fixing their value to zero. This is appropriate, for example, when dropping noise or disturbance inputs from a closed-loop model. When operating around a trajectory or trim condition, however, discarded inputs must be held at their trim value to maintain the desired operating condition. You can then use fixInput to assign nonzero values to the discarded inputs.

    asys = fixInput(sys,J,UJ) fixes the J-th input to the value UJ and deletes it.

    asys = fixInput(sys,J,'u0') equates the J-th input with the J-th entry of the input offset u0, u0(t), or u0(t,p) specified in the model. When u0 is the input level to achieve steady state or follow a given trajectory. This syntax is useful to maintain the system in the desired operating regime while manipulating the remaining inputs.

    asys = fixInput(sys,indices,values) fixes and deletes several inputs at once.

    example

    Examples

    collapse all

    This example shows how to use fixInput fix inputs to a nonzero value and discard them. This is helpful when maintain the system in the desired operating range while manipulating the remaining inputs.

    Create a random three-input three-output model with offsets.

    rng(0), 
    sys = rss(2,2,3);
    sys.Offsets = struct('dx',randn(2,1),...
            'x',randn(2,1),'u',randn(3,1),'y',randn(2,1));

    Using the fixInput function, you can fix single or multiple input channels. Additionally, you can fix these inputs to a numeric value or the input offset u0 value of that channel

    Fix the second input to a numeric value.

    asys1 = fixInput(sys,2,0.5);

    Fix the third input to the corresponding input offset u0(3).

    asys2 = fixInput(sys,3,'u0');

    Fix the second and third inputs to numeric values.

    asys3 = fixInput(sys,[2 3],[-0.5 0.7]);

    Fix the second input to u0(2) and third input to a numeric value. To specify this mix of values, use a cell array.

    asys4 = fixInput(sys,[2 3],{'u0' 0.7});

    Input Arguments

    collapse all

    State-space model with offsets, specified as a ss, sparss, ltvss, or lpvss object.

    Input channel index, specified as a positive integer with value between 1 and number of inputs.

    Input value corresponding to the J-th input channel, specified as a scalar.

    Input channel indices, specified as a vector of positive and unique integers. Each value in this vector must be between 1 and number of inputs and you can not specify an input channel multiple times.

    Fixed input values, specified as one of these values.

    • 'u0' — Fix the specified indices to the corresponding entries of the input offsets u0, u0(t), or u0(t,p).

      For example, the syntax asys = fixInput(sys,[2 3],'u0') fixes u(2) to u0(2) and u(3) to u0(3).

    • Scalar — Fix all the specified indices to a numeric scalar value.

      For example, the syntax asys = fixInput(sys,[2 3],-2) fixes u(2) and u(3) to -2.

    • Vector of numeric values — Fix the indices specified in indices to the corresponding entry in this vector of numeric values. This vector must be of the same length as indices.

      For example, the syntax asys = fixInput(sys,[2 3],[-0.5 0.7]) fixes u(2) = -0.5 and u(3) = 0.7.

    • Cell array — Specify a cell array with a mix of numeric values and 'u0'. Fix the indices specified in indices to the corresponding entry in this cell array. This cell array must be of the same length as indices.

      For example, the syntax asys = fixInput(sys,[2 3],['u0' 0.7]) fixes u(2) = u0(2) and u(3) = 0.7.

    Output Arguments

    collapse all

    Modified state-space model, returned as a model of same type as sys.

    Version History

    Introduced in R2024a

    See Also

    | | |