Question: I need help with my MATLAB code. If I have multiples files of data, for example vBody 1 , vBody 2 , vRef 1 ,
I need help with my MATLAB code. If I have multiples files of data, for example vBody vBody vRef vRef I don't want to copy and paste this code again and again. Can you help me create a function of this code.
Initializing arrays
z zeros;
Bmat zeros;
nostars lengthvBody;
Creating for loop to find B and z of the Davenport's qmethod
for i :nostars
Extracting the vectors
b vBody: i;
r vRef: i;
Creating the B matrix
Bmat Bmat b r;
Creating the z vector
z z crossb r;
end
Calculating the K matrix
K Bmat Bmat' traceBmat eye;
Kmat K z ; z traceBmat;
Finding the eigenvalues and q vectors
qvec, eigs eigKmat 'vector';
Finding the biggest eigenvalue and its q vector
lambda i maxeigs;
q qvec: i;
qhat q normq;
Calculating the DCM using the function
Adavenport qDCMq;
Confirm that lambdadave is close to lambda
lambdainit nostars;
difflambda lambdainit lambda;
function skewmat Skewv
This function creates the skew symmetric matrix of a vector
skewmat v v; vv; v v;
end
function A qDCMq
This function creates the rotation matrix by multiplying two matrices
Calculating psi and dont know what it is called
psi q eye Skewq:; q:;
greekletter q eye Skewq:; q:;
DCM
A greekletter' psi;
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
