-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfitModel_workspace.m
61 lines (51 loc) · 2.03 KB
/
fitModel_workspace.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
clc;
clear;
close all;
weight_W = 0.8; % percent winding RMSE weighted in opimizaiton function
% x0 = [1 1 1 1 1];
x0 = [20 20 0.1 150 10];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0 0 0 0 0];
ub = [];
nonlcon = [];
skip_outputside = load("skip_outputside_5A_compiled_20240313.mat", "data");
skip_motorside = load("skip_motorside_5A_compiled_20240313.mat", "data");
t = {skip_motorside.data.t, skip_outputside.data.t};
q = {skip_motorside.data.q, skip_outputside.data.q};
active = {skip_motorside.data.active, []};
inactive = {skip_motorside.data.inactive, []};
frame = {[], skip_outputside.data.frame};
T_ambient = {skip_motorside.data.ambient, skip_outputside.data.ambient};
skip_model = thermalModel;
% options = optimoptions("fmincon", "Display", "iter");
% skip_model.fit_fmincon(x0, A, b, Aeq, beq, lb, ub, nonlcon, options,...
% t, q, active, inactive, frame, T_ambient, weight_W, 1);
options = optimoptions('ga','PlotFcn', @gaplotbestf);
skip_model.fit_ga(length(x0), A, b, Aeq, beq, lb, ub, nonlcon, options,...
t, q, active, inactive, frame, T_ambient, weight_W, 1);
%%
% figure(1);
% subplot(1,2,1);
% plot(MN1005_8A.data.t, (MN1005_8A.data.active + 2*MN1005_8A.data.inactive)/3, 'Color', '#0072BD');
% hold on;
% plot(skip_model.t_train, skip_model.TW_train, 'Color', '#D95319');
% plot(MN1005_8A.data.t, MN1005_8A.data.frame, 'Color', '#0072BD', 'HandleVisibility', 'off');
% plot(skip_model.t_train, skip_model.TH_train, 'Color', '#D95319', 'HandleVisibility', 'off');
% hold off;
% xlabel('Time (sec)');
% ylabel('Temperature (^oC)');
% title('MN1005, Train 8A');
% legend('Data', 'Model');
%
% subplot(1,2,2);
% plot(MN1005_9A.data.t, (MN1005_9A.data.active + 2*MN1005_9A.data.inactive)/3, 'Color', '#0072BD');
% hold on;
% plot(skip_model.t_test, skip_model.TW_test, 'Color', '#D95319');
% plot(MN1005_9A.data.t, MN1005_9A.data.frame, 'Color', '#0072BD', 'HandleVisibility', 'off');
% plot(skip_model.t_test, skip_model.TH_test, 'Color', '#D95319', 'HandleVisibility', 'off');
% hold off;
% xlabel('Time (sec)');
% title('MN1005, Test 9A');