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
|
%% please open Magic Formular APP first
|
||||||
clear
|
clear
|
||||||
n = 20
|
n = 20;
|
||||||
mkdir('similarityData');
|
mkdir('similarityData');
|
||||||
%%
|
%%
|
||||||
directoryPath = "..\sorted_data";
|
directoryPath = "..\sorted_data";
|
||||||
|
@ -12,47 +12,73 @@ fileNames = {files.name};
|
|||||||
for n=1:length(fileNames)
|
for n=1:length(fileNames)
|
||||||
% fit the curve of 43075 , 8 inch
|
% fit the curve of 43075 , 8 inch
|
||||||
filePath = fullfile(directoryPath, fileNames(n));
|
filePath = fullfile(directoryPath, fileNames(n));
|
||||||
load(filePath)
|
load(filePath);
|
||||||
[fitresult, gof] = createFit(SAA{8},FYY{8});
|
[fitresult, gof] = createFit(SAA{8},FYY{8});
|
||||||
residual = [];
|
|
||||||
|
|
||||||
% Evaluate the fitted curves
|
% Evaluate the fitted curves
|
||||||
for i=1:length(SAA)
|
for tire=1:length(SAA)
|
||||||
y_fit = fitresult(SAA{i});
|
y_fit = fitresult(SAA{tire});
|
||||||
% Calculate residuals
|
% Calculate residuals
|
||||||
residual = [residual, mean(abs(FYY{i} - y_fit))];
|
residuals{tire}{n} = abs(FYY{tire} - fitresult(SAA{tire}));
|
||||||
end
|
end
|
||||||
residuals{n} = residual;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1:length(residual)
|
for tire=1:length(SAA)
|
||||||
residuals_sum{i} = 0;
|
residuals_one_tire = [];
|
||||||
num = length(fileNames);
|
for n=1:length(fileNames)
|
||||||
for j=1:length(fileNames)
|
residuals_one_tire = [residuals_one_tire; residuals{tire}{n}];
|
||||||
if isnan(residuals{j}(i))
|
|
||||||
num = num - 1;
|
|
||||||
residuals{j}(i) = 0;
|
|
||||||
end
|
|
||||||
residuals_sum{i} = residuals{j}(i) + residuals_sum{i};
|
|
||||||
end
|
end
|
||||||
residuals_mean{i} = residuals_sum{i}/num;
|
residuals_tire{tire} = residuals_one_tire;
|
||||||
end
|
end
|
||||||
% figure()
|
%% mean
|
||||||
% idx = linspace(1,length(SAA),length(SAA));
|
for tire=1:length(SAA)
|
||||||
% for i=1:length(fileNames)
|
num = 0;
|
||||||
% plot(idx, residuals{i}, "-*")
|
% each tire under 60 measurement conditions
|
||||||
% hold on;
|
for i=1:length(residuals_tire{tire})
|
||||||
% end
|
if not(isnan(residuals_tire{tire}(i)))
|
||||||
% title("Residuials")
|
num = num + 1;
|
||||||
% legend(fileNames)
|
else
|
||||||
% xlabel("order of the tires(8 is our traget tire)")
|
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()
|
figure()
|
||||||
idx = linspace(1,length(SAA),length(SAA));
|
subplot(311)
|
||||||
y = cell2mat(residuals_mean)
|
y = cell2mat(residuals_mean);
|
||||||
plot(idx, y, "-*")
|
plot(idx, y, "-*")
|
||||||
title("Average Absolute Residuials")
|
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)
|
xticks(idx)
|
||||||
grid on
|
grid on
|
Loading…
x
Reference in New Issue
Block a user