-
Notifications
You must be signed in to change notification settings - Fork 4
/
estRS.m
37 lines (31 loc) · 1.26 KB
/
estRS.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [R,S]=estRS(M,K,G,Cq,Cqd)
%ESTRS: Establish the state-space matrices R and S
%Inputs: M - The mass matrix
% K - The stiffness matrix
% G - The gyroscopic matrix
% Cq - The Jacobian of the constraints
% Cqd - The partial derivative of C wrt qdot
%Output: R,S - The state-space matrices
%Call: [R,S]=estRS(M,K,G,Cq,Cqd)
%Copyright: Thomas Abrahamsson, Chalmers, Sweden
%Written: 2009-03-27
% -------------------------------------------------------------------------
% Initiate
% --------
nq=size(M,1);
nceq=size(Cq,1);
R=zeros(2*nq+nceq,2*nq+nceq);S=R;
% -------------------------------------------------------------------------
% Establish the matrices
% ----------------------
dofr=1:nq;
dofc=1:nq;R(dofr,dofc)=eye(nq,nq);
dofc=nq+[1:nq];S(dofr,dofc)=-eye(nq,nq);
dofr=nq+[1:nq];
dofc=nq+[1:nq];R(dofr,dofc)=M;
dofc=2*nq+[1:nceq];R(dofr,dofc)=Cqd';
dofc=[1:nq];S(dofr,dofc)=K;
dofc=nq+[1:nq];S(dofr,dofc)=G;
dofr=2*nq+[1:nceq];
dofc=1:nq;R(dofr,dofc)=Cq;
dofc=nq+[1:nq];R(dofr,dofc)=Cqd;