PT: plot to compare. Add Median und Mode
This commit is contained in:
parent
135739b8af
commit
96459e2b8f
@ -1,6 +1,6 @@
|
||||
%% please open Magic Formular APP first
|
||||
clear
|
||||
n = 20
|
||||
n = 20;
|
||||
mkdir('similarityData');
|
||||
%%
|
||||
directoryPath = "..\sorted_data";
|
||||
|
@ -12,47 +12,73 @@ fileNames = {files.name};
|
||||
for n=1:length(fileNames)
|
||||
% fit the curve of 43075 , 8 inch
|
||||
filePath = fullfile(directoryPath, fileNames(n));
|
||||
load(filePath)
|
||||
load(filePath);
|
||||
[fitresult, gof] = createFit(SAA{8},FYY{8});
|
||||
residual = [];
|
||||
|
||||
% Evaluate the fitted curves
|
||||
for i=1:length(SAA)
|
||||
y_fit = fitresult(SAA{i});
|
||||
for tire=1:length(SAA)
|
||||
y_fit = fitresult(SAA{tire});
|
||||
% Calculate residuals
|
||||
residual = [residual, mean(abs(FYY{i} - y_fit))];
|
||||
residuals{tire}{n} = abs(FYY{tire} - fitresult(SAA{tire}));
|
||||
end
|
||||
residuals{n} = residual;
|
||||
end
|
||||
|
||||
for i=1:length(residual)
|
||||
residuals_sum{i} = 0;
|
||||
num = length(fileNames);
|
||||
for j=1:length(fileNames)
|
||||
if isnan(residuals{j}(i))
|
||||
num = num - 1;
|
||||
residuals{j}(i) = 0;
|
||||
end
|
||||
residuals_sum{i} = residuals{j}(i) + residuals_sum{i};
|
||||
for tire=1:length(SAA)
|
||||
residuals_one_tire = [];
|
||||
for n=1:length(fileNames)
|
||||
residuals_one_tire = [residuals_one_tire; residuals{tire}{n}];
|
||||
end
|
||||
residuals_mean{i} = residuals_sum{i}/num;
|
||||
residuals_tire{tire} = residuals_one_tire;
|
||||
end
|
||||
% figure()
|
||||
% idx = linspace(1,length(SAA),length(SAA));
|
||||
% for i=1:length(fileNames)
|
||||
% plot(idx, residuals{i}, "-*")
|
||||
% hold on;
|
||||
% end
|
||||
% title("Residuials")
|
||||
% legend(fileNames)
|
||||
% xlabel("order of the tires(8 is our traget tire)")
|
||||
%% mean
|
||||
for tire=1:length(SAA)
|
||||
num = 0;
|
||||
% each tire under 60 measurement conditions
|
||||
for i=1:length(residuals_tire{tire})
|
||||
if not(isnan(residuals_tire{tire}(i)))
|
||||
num = num + 1;
|
||||
else
|
||||
residuals_tire{tire}(i) = 0;
|
||||
end
|
||||
end
|
||||
residuals_mean{tire} = sum(residuals_tire{tire})/num;
|
||||
end
|
||||
%% median
|
||||
for tire=1:length(SAA)
|
||||
residuals_median{tire} = median(residuals_tire{tire});
|
||||
end
|
||||
%% mode
|
||||
for tire=1:length(SAA)
|
||||
residuals_mode{tire} = mode(residuals_tire{tire});
|
||||
end
|
||||
|
||||
%% plots
|
||||
idx = linspace(1,length(SAA),length(SAA));
|
||||
|
||||
figure()
|
||||
idx = linspace(1,length(SAA),length(SAA));
|
||||
y = cell2mat(residuals_mean)
|
||||
subplot(311)
|
||||
y = cell2mat(residuals_mean);
|
||||
plot(idx, y, "-*")
|
||||
title("Average Absolute Residuials")
|
||||
legend(fileNames)
|
||||
xlabel("order of the tires(8 is our traget tire)")
|
||||
xlabel("Order of the tires(8 is our traget tire)")
|
||||
ylabel("in 1")
|
||||
xticks(idx)
|
||||
grid on
|
||||
|
||||
subplot(312)
|
||||
y = cell2mat(residuals_median);
|
||||
plot(idx, y, "-o")
|
||||
title("Median of the Absolute Residuials")
|
||||
xlabel("Order of the tires(8 is our traget tire)")
|
||||
ylabel("in 1")
|
||||
xticks(idx)
|
||||
grid on
|
||||
|
||||
|
||||
subplot(313)
|
||||
y = cell2mat(residuals_mode);
|
||||
plot(idx, y, "-o")
|
||||
title("Mode of the Absolute Residuials")
|
||||
xlabel("Order of the tires(8 is our traget tire)")
|
||||
ylabel("in 1")
|
||||
xticks(idx)
|
||||
grid on
|
Loading…
x
Reference in New Issue
Block a user