Question: I need help with my MATLAB code. I want to create a function of the following code, so if I have multiple S and z
I need help with my MATLAB code. I want to create a function of the following code, so if I have multiple S and z values.
S Bmat Bmat';
kappa traceadjointS;
Characteristic Equation Eqn
f @xx traceBmat kappax traceBmat
dotz zx traceBmatzSz detS
zSSz;
Derivative of the characteristic equation
df @xxx traceBmat dotz z
xx traceBmat kappazSz detS ;
Calculate the eigenvalue NewtonRaphson iteration
lambdas zeros;
lambdas;
step zeros;
quat zeros ;
DCM zeros ;
for i :
Xn flambdainit dflambdainit;
lambdainit lambdainit Xn;
get the corresponding attitude estimates
rho lambdainit traceBmat;
rhomat rho eye S;
qunit adjointrhomat z ; detrhomat;
qunit qunit normqunit;
store the step size and attitude estimate
stepi Xn;
lambdasi lambdainit;
quat: i qunit;
DCM: : i qDCMqunit;
Capture lambdainit and DCM after first and third iterations
if i
lambdaafterfirst lambdainit;
DCMafterfirst DCM: : i;
elseif i
lambdaafterthird lambdainit;
DCMafterthird DCM: : i;
end
end
Compare lambdainit after the first and third iterations
lambdadifference abslambdaafterthird lambdaafterfirst;
Compare DCM after the first and third iterations
DCMdifference absDCMafterthird DCMafterfirst;
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
