Merge branch 'main' of https://git.fasttube.de/t.korjakow/ft24_pacejka_tyre
This commit is contained in:
commit
b8dd225dab
40
scripts/createFit.m
Normal file
40
scripts/createFit.m
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
function [fitresult, gof] = createFit(SA, FY)
|
||||||
|
%CREATEFIT(SA,FY)
|
||||||
|
% Create a fit.
|
||||||
|
%
|
||||||
|
% Data for 'untitled fit 1' fit:
|
||||||
|
% X Input: SA
|
||||||
|
% Y Output: FY
|
||||||
|
% Output:
|
||||||
|
% fitresult : a fit object representing the fit.
|
||||||
|
% gof : structure with goodness-of fit info.
|
||||||
|
%
|
||||||
|
% See also FIT, CFIT, SFIT.
|
||||||
|
|
||||||
|
% Auto-generated by MATLAB on 04-Jan-2024 14:49:41
|
||||||
|
|
||||||
|
|
||||||
|
%% Fit: 'untitled fit 1'.
|
||||||
|
[xData, yData] = prepareCurveData( SA, FY );
|
||||||
|
|
||||||
|
% Set up fittype and options.
|
||||||
|
ft = fittype( 'fourier8' );
|
||||||
|
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
|
||||||
|
opts.Display = 'Off';
|
||||||
|
opts.MaxFunEvals = 100000;
|
||||||
|
opts.MaxIter = 50000;
|
||||||
|
opts.StartPoint = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7.29927003160889];
|
||||||
|
|
||||||
|
% Fit model to data.
|
||||||
|
[fitresult, gof] = fit( xData, yData, ft, opts );
|
||||||
|
|
||||||
|
% % Plot fit with data.
|
||||||
|
% figure( 'Name', 'untitled fit 1' );
|
||||||
|
% h = plot( fitresult, xData, yData );
|
||||||
|
% legend( h, 'FY vs. SA', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );
|
||||||
|
% % Label axes
|
||||||
|
% xlabel( 'SA', 'Interpreter', 'none' );
|
||||||
|
% ylabel( 'FY', 'Interpreter', 'none' );
|
||||||
|
% grid on
|
||||||
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
%% please open Magic Formular APP first
|
%% please open Magic Formular APP first
|
||||||
clear
|
clear
|
||||||
n = 20; % <=60
|
n = 20;
|
||||||
|
mkdir('similarityData');
|
||||||
%%
|
%%
|
||||||
directoryPath = "..\sorted_data";
|
directoryPath = "..\sorted_data";
|
||||||
subdirectories = getSubdirectories(directoryPath);
|
subdirectories = getSubdirectories(directoryPath);
|
||||||
@ -23,6 +24,7 @@ for i=1:length(subdirectories)
|
|||||||
measurement = measurements(n);
|
measurement = measurements(n);
|
||||||
|
|
||||||
[SX,SA,FZ,IP,IA,VX,FX,FY,MZ,MY,MX,W,T] = unpack(measurement);
|
[SX,SA,FZ,IP,IA,VX,FX,FY,MZ,MY,MX,W,T] = unpack(measurement);
|
||||||
|
FY = smoothdata(FY, "gaussian",100);
|
||||||
if i < length(subdirectories)/3
|
if i < length(subdirectories)/3
|
||||||
plot(SA, FY, 'LineWidth', 1)
|
plot(SA, FY, 'LineWidth', 1)
|
||||||
elseif i <= length(subdirectories)/3*2
|
elseif i <= length(subdirectories)/3*2
|
||||||
@ -30,9 +32,27 @@ for i=1:length(subdirectories)
|
|||||||
else
|
else
|
||||||
plot(SA, FY, '-.','LineWidth', 1)
|
plot(SA, FY, '-.','LineWidth', 1)
|
||||||
end
|
end
|
||||||
|
SAA{i} = SA;
|
||||||
|
FYY{i} = FY;
|
||||||
hold on
|
hold on
|
||||||
end
|
end
|
||||||
legend(subdirectoryNames{:})
|
legend(subdirectoryNames{:})
|
||||||
title("Similarities, n=",n)
|
title("Similarities, n=",n)
|
||||||
xlabel("Slip Angle")
|
xlabel("Slip Angle")
|
||||||
ylabel("FY")
|
ylabel("FY")
|
||||||
|
%% without plot
|
||||||
|
for n=1:60
|
||||||
|
for i=1:length(subdirectories)
|
||||||
|
fileMeasurement = fullfile("..\sorted_data", subdirectories{i}, "\cornering.mat");
|
||||||
|
parser = tydex.parsers.FSAETTC_SI_ISO_Mat();
|
||||||
|
measurements = parser.run(fileMeasurement);
|
||||||
|
measurement = measurements(n);
|
||||||
|
|
||||||
|
[SX,SA,FZ,IP,IA,VX,FX,FY,MZ,MY,MX,W,T] = unpack(measurement);
|
||||||
|
FY = smoothdata(FY, "gaussian",100);
|
||||||
|
SAA{i} = SA;
|
||||||
|
FYY{i} = FY;
|
||||||
|
end
|
||||||
|
file_name = ['similarityData\nEqu' num2str(n) '.mat'];
|
||||||
|
save(file_name, 'SAA', 'FYY');
|
||||||
|
end
|
||||||
|
84
scripts/similarities2.m
Normal file
84
scripts/similarities2.m
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
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});
|
||||||
|
% Evaluate the fitted curves
|
||||||
|
for tire=1:length(SAA)
|
||||||
|
y_fit = fitresult(SAA{tire});
|
||||||
|
% Calculate residuals
|
||||||
|
residuals{tire}{n} = abs(FYY{tire} - fitresult(SAA{tire}));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for tire=1:length(SAA)
|
||||||
|
residuals_one_tire = [];
|
||||||
|
for n=1:length(fileNames)
|
||||||
|
residuals_one_tire = [residuals_one_tire; residuals{tire}{n}];
|
||||||
|
end
|
||||||
|
residuals_tire{tire} = residuals_one_tire;
|
||||||
|
end
|
||||||
|
%% 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()
|
||||||
|
subplot(311)
|
||||||
|
y = cell2mat(residuals_mean);
|
||||||
|
plot(idx, y, "-*")
|
||||||
|
title("Average Absolute Residuials")
|
||||||
|
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