-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM2_MethodComparsions.m
62 lines (43 loc) · 1.97 KB
/
M2_MethodComparsions.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
clear; clc; close all;
load euler_e_angles.mat
load rk4_angles.mat
N = 6000; % number of samples
dt = 1; % time-step, seconds
T = linspace(0, N*dt, N); % time array
diff_angles = rk4_e_angles - e_euler_angles;
plot(T, diff_angles(:,1),"Color", "#011627", "LineWidth", 2.5)
hold on
xlabel("T (s)", 'FontSize', 20)
ylabel("RK4 - Euler", 'FontSize', 20)
grid on
plot(T, diff_angles(:,2),"Color", "#ff3366", "LineWidth", 2.5)
plot(T, diff_angles(:,3),"Color", "#ff7f11", "LineWidth", 2.5)
legend("\psi","\theta","\phi", "Location","northeast")
ax = gca;
ax.FontSize = 20;
ax.GridAlpha = 0.4;
set(gcf,'position',[0,0, 1280, 750])
v_norms = [2000 norm(e_euler_angles(2000,:)) norm(rk4_e_angles(2000,:));
4000 norm(e_euler_angles(4000,:)) norm(rk4_e_angles(4000,:));
6000 norm(e_euler_angles(6000,:)) norm(rk4_e_angles(6000,:))];
T = array2table(v_norms);
filename = 'vectorNorms.xlsx';
T.Properties.VariableNames = ["Time Step (s)","Euler Method (deg)", "RK4 Method (deg)"];
writetable(T,filename,'Sheet',1,'Range','A1')
%% Section C
DCM2000 = F2_Euler2DCM321(e_euler_angles(2000,1), e_euler_angles(2000,2), e_euler_angles(2000,3));
DCM4000 = F2_Euler2DCM321(e_euler_angles(4000,1), e_euler_angles(4000,2), e_euler_angles(4000,3));
DCM6000 = F2_Euler2DCM321(e_euler_angles(6000,1), e_euler_angles(6000,2), e_euler_angles(6000,3));
angles1 = F4_MatrixAngleNormalizerDeg(F7_DCM2Euler313(DCM2000));
angles2 = F4_MatrixAngleNormalizerDeg(F7_DCM2Euler313(DCM4000));
angles3 = F4_MatrixAngleNormalizerDeg(F7_DCM2Euler313(DCM6000));
T = array2table(angles1);
filename = 'DCM_Angles.xlsx';
T.Properties.VariableNames = ["Theta 1 deg","Theta 2 deg", "Theta 3 deg"];
writetable(T,filename,'Sheet',1,'Range','A1')
T = array2table(angles2);
T.Properties.VariableNames = ["Theta 1 deg","Theta 2 deg", "Theta 3 deg"];
writetable(T,filename,'Sheet',2,'Range','A1')
T = array2table(angles3);
T.Properties.VariableNames = ["Theta 1 deg","Theta 2 deg", "Theta 3 deg"];
writetable(T,filename,'Sheet',3,'Range','A1')