58 lines
1.6 KiB
Matlab
58 lines
1.6 KiB
Matlab
clear;
|
|
clc;
|
|
% Use the dir function to get information about files and directories
|
|
directoryPath = ".\similarityData";
|
|
|
|
% Get a list of all files in the directory
|
|
files = dir(fullfile(directoryPath, '*.mat')); % You can adjust the file extension as needed
|
|
|
|
% Extract file names
|
|
fileNames = {files.name};
|
|
|
|
for n=1:length(fileNames)
|
|
% fit the curve of 43075 , 8 inch
|
|
filePath = fullfile(directoryPath, fileNames(n));
|
|
load(filePath)
|
|
[fitresult, gof] = createFit(SAA{8},FYY{8});
|
|
residual = [];
|
|
|
|
% Evaluate the fitted curves
|
|
for i=1:length(SAA)
|
|
y_fit = fitresult(SAA{i});
|
|
% Calculate residuals
|
|
residual = [residual, mean(abs(FYY{i} - y_fit))];
|
|
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};
|
|
end
|
|
residuals_mean{i} = residuals_sum{i}/num;
|
|
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)")
|
|
|
|
figure()
|
|
idx = linspace(1,length(SAA),length(SAA));
|
|
y = cell2mat(residuals_mean)
|
|
plot(idx, y, "-*")
|
|
title("Average Absolute Residuials")
|
|
legend(fileNames)
|
|
xlabel("order of the tires(8 is our traget tire)")
|
|
xticks(idx)
|
|
grid on |