mech_transfer_states

Map states from one machine's state vector manager to another

Syntax

dststates = mech_transfer_states(srcMgr, dstMgr, transferstruct)
dststates = mech_transfer_states(srcMgr, dstMgr, transferstruct, srcstates)
dststates = mech_transfer_states(srcMgr, dstMgr, transferstruct, srcstates, dststates)

Description

dststates = mech_transfer_states(srcMgr, dstMgr, transferstruct) copies selected state entries from the source state vector manager srcMgr to the state vector dststates, which can be assigned to dstMgr.X, where dstMgr is the state vector manager for the destination machine. The states to be copied are specified in transferstruct. Any destination states not specified in transferstruct retain their values as specified initially in dstMgr.

dststates = mech_transfer_states(srcMgr, dstMgr, transferstruct, srcstates) performs the same transfer, but takes the "source" states in srcstates rather than the values in srcMgr.X.

dststates = mech_transfer_states(srcMgr, dstMgr, transferstruct, srcstates, dststates) performs the same transfer, but also takes the "destination" states in dststates rather than the values in dstMgr.X for those destination states that are not the target of an assignment.

Input Arguments

mech_transfer_states accepts three, four, or five inputs.

srcMgr

A state vector manager for the source system. It is an object of the MECH.StateVectorMgr class as returned by the mech_stateVectorMgr function. This input is required.

dstMgr

A state vector manager for the destination system. It is an object of the MECH.StateVectorMgr class as returned by the mech_stateVectorMgr function. This input is required.

transferstruct

A structured array whose src and dst fields contain either the indices or the names of the source and destination states as known to their respective state managers. This input is required.

Either or both of the dst and src fields in transferstruct can also be indices for their respective vector manager's X vectors.

srcstates

A source mechanical state vector. This input is optional.

dststates

A destination mechanical state vector. This input is optional and requires the optional fourth input.

Output Arguments

dststates

The destination mechanical state vector.

Examples

Copying Mechanical States

Copy the first state in srcMgr to the third state in dstMgr:

transferstruct(1).src=srcMgr.StateNames{1};
transferstruct(1).dst=dstMgr.StateNames{3};
dstMgr.X = mech_transfer_states(srcMgr, dstMgr, transferstruct);

Using transferstruct Fields as Mechanical State Vector Manager Indices

Define the same transferstruct structure as in the preceding example.

If both of the dst and src fields in transferstruct are indices for their respective vector manager's X vectors, this function is equivalent to:

dststates(transferstruct.dst) = srcstates(transferstruct.src)
Was this topic helpful?