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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
function [structure]=optim2(file_temp, file_hardness, tab_hardness, file_created)
%% Utilisation
% Pour utiliser ce code, il faut avoir un fichier Excel avec les duretés en R7. Il faut donner le nom exact de la feuille.
% Le fichier de température doit avoir le temps dans la colonne 2, et les températures suivant la position dans les colonnes 3 et suivantes.
%% DATA
% Get values of the hardness
Excel = actxserver('Excel.Application');
set(Excel, 'Visible', false);
xlspath = 'H:\Projet' ;
xlsfile = file_hardness ;
Workbook = Excel.Workbooks.Open(fullfile(xlspath,xlsfile));
ActiveSheet = Excel.Worksheets.Item(tab_hardness);
r(1) = ActiveSheet.Range('R7');
r(2) = ActiveSheet.Range('R7').End('xlDown');
ydata = ActiveSheet.get('Range',r(1),r(2)).Value;
% Workbook.Close(false);
% Quit(Excel);
% delete(Excel)
% clear Excel
% Get values of temperature, etc...
fichier=dlmread(file_temp);
% Looking for the number of data, [line columns]
nb_data=size(fichier);
xdata=fichier(:,3:nb_data(2));
%% OPTIM
% script to optimise ki values in classical QFA (eq. 3 and not 4 in Shuhui
% Ma et al.) with Sigma_min=0 and Avrami exponent n = 1
% upper bound
ku = [30.0 10.0 10.0 20.00];
% lower bound
kl = [1 1 1 1];
% initial guess
k0 = [7.0000 7.9800 7.7800 13.0056];
[k,RESNORM,RESIDUAL,EXITFLAG,OUTPUT]= lsqcurvefit('fun', k0, xdata, ydata, kl, ku);
%% Creation of the structure
structure.HV = HV_pred;
structure.k = k;
structure.Q = Q;
%% Creation of the file with the data
dlmwrite(file_created,structure.HV);
dlmwrite(file_created,structure.Q,'-append');
dlmwrite(file_created,structure.k,'-append');
%% Graphics
figure(2)
for i=1:30
x(i) =i;
end
% Superposition points expérimentaux et fittés.
plot (x, ydata, '*r', x, fun(k, xdata), '+b')
xlabel('Position');
ylabel('HV');
title('Strength in function of the position');
figure(3)
plot(x, fun(k,xdata))
figure(4)
plot(fun(k,xdata),ydata)
xlabel('HV predicted');
ylabel('HV measured');
title('HV predicted VS HV measured'); |
Partager