Skip to content

Commit

Permalink
debugged plot and calculation of Weibull cdf
Browse files Browse the repository at this point in the history
  • Loading branch information
david mercier committed Sep 2, 2015
1 parent be67ca9 commit c35c806
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
42 changes: 22 additions & 20 deletions matlab_code/get_and_plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

[maxpeak, minpeak] = peakdet(gui.data(ii_sheet).data_ddh_cleaned(:), delta_data);

% Attribution of pop-in indice(s) for each load-disp curve
% (for each Excel sheet)...
gui.data(ii_sheet).num_popin_int = maxpeak(:, 1);

if gui.data(ii_sheet).num_popin_int == -1;
Expand Down Expand Up @@ -101,19 +103,16 @@

end

% Extraction of values of load or disp at the pop-in
% indice obtained from peak detection (see above)
if gui.settings.value_crit_param == 1
gui.data(ii_sheet).sum_L = ...
gui.data(ii_sheet).data_L_cleaned(ind_popin);

gui.data(ii_sheet).mean_sum_L = ...
mean(gui.data(ii_sheet).sum_L);

elseif gui.settings.value_crit_param == 2
gui.data(ii_sheet).sum_h = ...
gui.data(ii_sheet).data_h_cleaned(ind_popin);

gui.data(ii_sheet).mean_sum_h = ...
mean(gui.data(ii_sheet).sum_h);
end
guidata(gcf, gui);
end
Expand All @@ -123,38 +122,41 @@
%% Set the data to plot
if gui.settings.value_crit_param == 1
for ii = 1:1:length(gui.data)
gui.results(ii).binCtrs = gui.data(ii).sum_L / mean([gui.data.mean_sum_L]);
gui.results(ii).max_binCtrs = max([gui.data(ii).sum_L]);
gui.results(ii).binCtrs_init = gui.data(ii).sum_L;
gui.results(ii).binCtrs = gui.data(ii).sum_L / mean([gui.data.sum_L]);
end
gui.resultsMax_binCtrs = max([gui.data.sum_L]);
elseif gui.settings.value_crit_param == 2
for ii = 1:1:length(gui.data)
gui.results(ii).binCtrs = gui.data(ii).sum_h / mean([gui.data.mean_sum_h]);
gui.results(ii).max_binCtrs = max([gui.data(ii).sum_h]);
gui.results(ii).binCtrs_init = gui.data(ii).sum_h;
gui.results(ii).binCtrs = gui.data(ii).sum_h / mean([gui.data.sum_h]);
end
gui.resultsMax_binCtrs = max([gui.data.sum_h]);
end

if strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(1,:)) || ...
strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(3,:))
xdata_init = sort([gui.results(:).binCtrs_init]);
xdata = sort([gui.results(:).binCtrs]);
for ii = 1:1:length(gui.data)
gui.results(ii).xdata = xdata(ii);
end

elseif strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(2,:)) || ...
strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(4,:))
xdata_init = sort([gui.results(:).binCtrs_init],'descend');
xdata = sort([gui.results(:).binCtrs],'descend');
for ii = 1:1:length(gui.data)
gui.results(ii).xdata = xdata(ii);
end

else
xdata = sort([gui.data(:).sum_L]);
xdata_init = xdata;
for ii = 1:1:length(gui.data)
if xdata(ii) < 0
xdata(ii) = 0;
end
gui.results(ii).xdata = xdata(ii);
end

end
for ii = 1:1:length(gui.data)
gui.results(ii).xdata_init = xdata_init(ii);
gui.results(ii).xdata = xdata(ii);
end

for ii = 1:1:length(gui.data)
Expand All @@ -170,13 +172,13 @@

% Calculations of the cumulative function
if strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(1,:))
weibull_cdf(OPTIONS, [gui.results.xdata],[gui.results.ydata]);
weibull_cdf(OPTIONS, [gui.results.xdata_init],[gui.results.ydata]);
elseif strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(2,:))
weibull_cdf_survival(OPTIONS, [gui.results.xdata],[gui.results.ydata]);
weibull_cdf_survival(OPTIONS, [gui.results.xdata_init],[gui.results.ydata]);
elseif strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(3,:))
weibull_modified_cdf(OPTIONS, [gui.results.xdata],[gui.results.ydata]);
weibull_modified_cdf(OPTIONS, [gui.results.xdata_init],[gui.results.ydata]);
elseif strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(4,:))
weibull_modified_cdf_survival(OPTIONS, [gui.results.xdata],[gui.results.ydata]);
weibull_modified_cdf_survival(OPTIONS, [gui.results.xdata_init],[gui.results.ydata]);
elseif strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(5,:))
mason_cdf(OPTIONS, [gui.results.xdata],[gui.results.ydata]);
end
Expand Down
11 changes: 6 additions & 5 deletions matlab_code/plot/plot_cdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(3,:)) || ...
strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(4,:))
str_title = ['Mean critical parameter=', ...
num2str(coefEsts(2) * mean([gui.data(:).mean_sum_L])), ...
num2str(coefEsts(2)), ...
' & Weibull modulus=', num2str(coefEsts(1))];
%str_xlabel = 'Critical load (mN)';
str_xlabel = 'Ratio of the critical load to the average critical load)';
str_xlabel = 'Ratio of the critical load to the average critical load';
else
str_title = strcat('{\eta}=', num2str(coefEsts(1)), ...
' & {\epsilon}=', num2str(coefEsts(2)), ...
Expand All @@ -59,10 +59,10 @@
strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(3,:)) || ...
strcmp(gui.settings.cumulFunction, gui.settings.cumulFunctionList(4,:))
str_title = strcat('Mean critical parameter=', ...
num2str(coefEsts(2) * mean([gui.data(:).mean_sum_h])), ...
num2str(coefEsts(2)), ...
' & Weibull modulus=', num2str(coefEsts(1)));
%str_xlabel = 'Critical displacement (nm)';
str_xlabel = 'Ratio of the critical displacement to the average critical displacement)';
str_xlabel = 'Ratio of the critical displacement to the average critical displacement';
else
str_title = strcat('{\eta}=', num2str(coefEsts(1)), ...
' & {\epsilon}=', num2str(coefEsts(2)), ...
Expand All @@ -71,7 +71,8 @@
end
end

line(gui.cumulativeFunction.xdata_cdf, gui.cumulativeFunction.ydata_cdf, ...
line(gui.cumulativeFunction.xdata_cdf./gui.cumulativeFunction.coefEsts(2), ...
gui.cumulativeFunction.ydata_cdf, ...
'Color', 'r', 'LineWidth', 2);

legend({'Row data' 'Weibull model'}, 'Location', 'NorthWest');
Expand Down
4 changes: 2 additions & 2 deletions matlab_code/statistics/weibull/weibull_cdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function weibull_cdf(OPTIONS, xdata_fit, ydata_fit)
% Make a starting guess of coefficients p(1) and p(2)
% p(1) = Weibull modulus --> 10 when good homogeneity in size defect distribution
% p(2) = Mean critical value
gui.cumulativeFunction.p0 = [1 ; mean(ydata_fit)];
gui.cumulativeFunction.p0 = [1 ; mean(xdata_fit)];

[gui.cumulativeFunction.coefEsts, ...
gui.cumulativeFunction.resnorm, ...
Expand All @@ -26,7 +26,7 @@ function weibull_cdf(OPTIONS, xdata_fit, ydata_fit)
lsqcurvefit(weibull_cdf_m, gui.cumulativeFunction.p0, ...
gui.cumulativeFunction.xdata_cdf, ydata_fit, ...
[gui.config.numerics.Min_mWeibull ; 0], ...
[gui.config.numerics.Max_mWeibull ; max(ydata_fit)], ...
[gui.config.numerics.Max_mWeibull ; max(xdata_fit)], ...
OPTIONS);

gui.cumulativeFunction.coefEsts(1) = ...
Expand Down
4 changes: 2 additions & 2 deletions matlab_code/statistics/weibull/weibull_cdf_survival.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function weibull_cdf_survival(OPTIONS, xdata_fit, ydata_fit)
% Make a starting guess of coefficients p(1) and p(2)
% p(1) = Weibull modulus --> 10 when good homogeneity in size defect distribution
% p(2) = Mean critical value
gui.cumulativeFunction.p0 = [1 ; mean(ydata_fit)];
gui.cumulativeFunction.p0 = [1 ; mean(xdata_fit)];

[gui.cumulativeFunction.coefEsts, ...
gui.cumulativeFunction.resnorm, ...
Expand All @@ -26,7 +26,7 @@ function weibull_cdf_survival(OPTIONS, xdata_fit, ydata_fit)
lsqcurvefit(weibull_cdf_s, gui.cumulativeFunction.p0, ...
gui.cumulativeFunction.xdata_cdf, ydata_fit, ...
[gui.config.numerics.Min_mWeibull ; 0], ...
[gui.config.numerics.Max_mWeibull ; max(ydata_fit)], ...
[gui.config.numerics.Max_mWeibull ; max(xdata_fit)], ...
OPTIONS);

gui.cumulativeFunction.coefEsts(1) = ...
Expand Down
6 changes: 3 additions & 3 deletions matlab_code/statistics/weibull/weibull_modified_cdf.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function weibull_modified_cdf(OPTIONS, xdata_fit, ydata_fit)
% p(1) = Weibull modulus --> 10 when good homogeneity in size defect distribution
% p(2) = Mean critical value
gui.cumulativeFunction.p0 = ...
[1 ; mean(ydata_fit)];
[1 ; mean(xdata_fit)];

[gui.cumulativeFunction.coefEsts, ...
gui.cumulativeFunction.resnorm, ...
Expand All @@ -25,7 +25,7 @@ function weibull_modified_cdf(OPTIONS, xdata_fit, ydata_fit)
lsqcurvefit(weibull_cdf_m, gui.cumulativeFunction.p0, ...
gui.cumulativeFunction.xdata_cdf, ydata_fit, ...
[gui.config.numerics.Min_mChechenin ; 0], ...
[gui.config.numerics.Max_mChechenin ; max(ydata_fit)], ...
[gui.config.numerics.Max_mChechenin ; max(xdata_fit)], ...
OPTIONS);

gui.cumulativeFunction.coefEsts(1) = ...
Expand All @@ -34,7 +34,7 @@ function weibull_modified_cdf(OPTIONS, xdata_fit, ydata_fit)
real(gui.cumulativeFunction.coefEsts(2));

gui.cumulativeFunction.ydata_cdf = ...
(1 - exp(-(gui.cumulativeFunction.xdata_cdf./gui.cumulativeFunction.coefEsts(2)) ...
(1 - exp(-log(2) .* (gui.cumulativeFunction.xdata_cdf./gui.cumulativeFunction.coefEsts(2)) ...
.^ gui.cumulativeFunction.coefEsts(1)));

guidata(gcf, gui);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function weibull_modified_cdf_survival(OPTIONS, xdata_fit, ydata_fit)
% p(1) = Weibull modulus --> 10 when good homogeneity in size defect distribution
% p(2) = Mean critical value
gui.cumulativeFunction.p0 = ...
[1 ; mean(ydata_fit)];
[1 ; mean(xdata_fit)];

[gui.cumulativeFunction.coefEsts, ...
gui.cumulativeFunction.resnorm, ...
Expand All @@ -25,7 +25,7 @@ function weibull_modified_cdf_survival(OPTIONS, xdata_fit, ydata_fit)
lsqcurvefit(weibull_cdf_s, gui.cumulativeFunction.p0, ...
gui.cumulativeFunction.xdata_cdf, ydata_fit, ...
[gui.config.numerics.Min_mChechenin ; 0], ...
[gui.config.numerics.Max_mChechenin ; max(ydata_fit)], ...
[gui.config.numerics.Max_mChechenin ; max(xdata_fit)], ...
OPTIONS);

gui.cumulativeFunction.coefEsts(1) = ...
Expand All @@ -34,7 +34,7 @@ function weibull_modified_cdf_survival(OPTIONS, xdata_fit, ydata_fit)
real(gui.cumulativeFunction.coefEsts(2));

gui.cumulativeFunction.ydata_cdf = ...
exp(-(gui.cumulativeFunction.xdata_cdf./gui.cumulativeFunction.coefEsts(2)) ...
exp(-log(2) .* (gui.cumulativeFunction.xdata_cdf./gui.cumulativeFunction.coefEsts(2)) ...
.^ gui.cumulativeFunction.coefEsts(1));

guidata(gcf, gui);
Expand Down

0 comments on commit c35c806

Please sign in to comment.