主要内容

stateparts

Get or set value of state part in insCF

Since R2026a

    Description

    part = stateparts(filter,stateName) returns the value of the state part specified by stateName.

    example

    stateparts(filter,stateName,value) sets the value of the specified state part stateName to the specified value.

    example

    Examples

    collapse all

    Create an insCF object for orientation estimation.

    filterO = insCF;

    Get the orientation from the complementary filter. The function returns the default orientation value.

    orientation = stateparts(filterO,"Orientation")
    orientation = 1×4
    
         1     0     0     0
    
    

    Set the orientation to a new value.

    stateparts(filterO,"Orientation",[1 0.05 0.5 0])

    Get the new orientation from the filter.

    orientation = stateparts(filterO,"Orientation")
    orientation = 1×4
    
        1.0000    0.0500    0.5000         0
    
    

    Create an insCF filter object for pose estimation.

    filterP = insCF(insCFGyroscope,insCFAccelerometer,insCFGPS);

    Get the position from the complementary filter. The function returns the default position value.

    position = stateparts(filterP,"Position")
    position = 1×3
    
         0     0     0
    
    

    Set the position to a new value.

    stateparts(filterP,"Position",[2 1.5 0])

    Get the new position.

    position = stateparts(filterP,"Position")
    position = 1×3
    
        2.0000    1.5000         0
    
    

    Input Arguments

    collapse all

    Complementary filter, specified as an insCF object.

    State part name, specified as "Orientation", "Position", or "Velocity". If you specify a filter created to track only orientation, then you must specify this state part name as "Orientation".

    Value for the filter state part, specified as an N-element row vector, where N is the number of elements in the state part vector. You must specify this value in the format that corresponds to the specified state part.

    StateValue Format
    Orientation[w x y z], representing four parts of quaternion
    Position

    [x y z], where each element is in meters

    Velocity

    [vx vy vz], where each element is in meters per second

    Example: stateparts(insCF,"Orientation",[1 0.05 0.5 0]) sets the value for the orientation filter state part of insCF to [1 0.05 0.5 0].

    Data Types: double

    Output Arguments

    collapse all

    State part value, returned as a N-element row vector. N is the number of elements in the state part. The format of the vector depends on the specified state part.

    StateValue Format
    Orientation[w x y z], representing four parts of quaternion
    Position

    [x y z], where each element is in meters

    Velocity

    [vx vy vz], where each element is in meters per second

    Data Types: double

    Extended Capabilities

    expand all

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2026a

    See Also

    Objects

    Functions