function [pd1,pd2,pd3,pd4] = createFit(arg_1,arg_2,arg_3,arg_4) %CREATEFIT Create plot of datasets and fits % [PD1,PD2,PD3,PD4] = CREATEFIT(ARG_1,ARG_2,ARG_3,ARG_4) % Creates a plot, similar to the plot in the main distribution fitter % window, using the data that you provide as input. You can % apply this function to the same data you used with dfittool % or with different data. You may want to edit the function to % customize the code and this help message. % % Number of datasets: 4 % Number of fits: 4 % % See also FITDIST. % This function was automatically generated on 09-Jul-2019 18:37:48 % Output fitted probablility distributions: PD1,PD2,PD3,PD4 % Data from dataset "PE-5% Lignin": % Y = arg_1 (originally a(:,2)) % Data from dataset "PE-10% Lignin": % Y = arg_2 (originally b(:,2)) % Data from dataset "PE-15% Lignin": % Y = arg_3 (originally c(:,2)) % Data from dataset "PE-30% blend": % Y = arg_4 (originally d(:,2)) % Force all inputs to be column vectors arg_1 = arg_1(:); arg_2 = arg_2(:); arg_3 = arg_3(:); arg_4 = arg_4(:); % Prepare figure clf; hold on; LegHandles = []; LegText = {}; % --- Plot data originally in dataset "PE-5% Lignin" [CdfF,CdfX] = ecdf(arg_1,'Function','cdf'); % compute empirical cdf BinInfo.rule = 1; [~,BinEdge] = internal.stats.histbins(arg_1,[],[],BinInfo,CdfF,CdfX); [BinHeight,BinCenter] = ecdfhist(CdfF,CdfX,'edges',BinEdge); hLine = bar(BinCenter,BinHeight,'hist'); set(hLine,'FaceColor','none','EdgeColor',[0.333333 0 0.666667],... 'LineStyle','-', 'LineWidth',1); xlabel('Data'); ylabel('Density') LegHandles(end+1) = hLine; LegText{end+1} = 'PE-5% Lignin'; % --- Plot data originally in dataset "PE-10% Lignin" [CdfF,CdfX] = ecdf(arg_2,'Function','cdf'); % compute empirical cdf BinInfo.rule = 1; [~,BinEdge] = internal.stats.histbins(arg_2,[],[],BinInfo,CdfF,CdfX); [BinHeight,BinCenter] = ecdfhist(CdfF,CdfX,'edges',BinEdge); hLine = bar(BinCenter,BinHeight,'hist'); set(hLine,'FaceColor','none','EdgeColor',[0.333333 0.666667 0],... 'LineStyle','-', 'LineWidth',1); xlabel('Data'); ylabel('Density') LegHandles(end+1) = hLine; LegText{end+1} = 'PE-10% Lignin'; % --- Plot data originally in dataset "PE-15% Lignin" [CdfF,CdfX] = ecdf(arg_3,'Function','cdf'); % compute empirical cdf BinInfo.rule = 1; [~,BinEdge] = internal.stats.histbins(arg_3,[],[],BinInfo,CdfF,CdfX); [BinHeight,BinCenter] = ecdfhist(CdfF,CdfX,'edges',BinEdge); hLine = bar(BinCenter,BinHeight,'hist'); set(hLine,'FaceColor','none','EdgeColor',[0 0 0],... 'LineStyle','-', 'LineWidth',1); xlabel('Data'); ylabel('Density') LegHandles(end+1) = hLine; LegText{end+1} = 'PE-15% Lignin'; % --- Plot data originally in dataset "PE-30% blend" [CdfF,CdfX] = ecdf(arg_4,'Function','cdf'); % compute empirical cdf BinInfo.rule = 1; [~,BinEdge] = internal.stats.histbins(arg_4,[],[],BinInfo,CdfF,CdfX); [BinHeight,BinCenter] = ecdfhist(CdfF,CdfX,'edges',BinEdge); hLine = bar(BinCenter,BinHeight,'hist'); set(hLine,'FaceColor','none','EdgeColor',[0.333333 1 0.666667],... 'LineStyle','-', 'LineWidth',1); xlabel('Data'); ylabel('Density') LegHandles(end+1) = hLine; LegText{end+1} = 'PE-30% blend'; % Create grid where function will be computed XLim = get(gca,'XLim'); XLim = XLim + [-1 1] * 0.01 * diff(XLim); XGrid = linspace(XLim(1),XLim(2),100); % --- Create fit "Distribution for 5% blend" % Fit this distribution to get parameter values % To use parameter estimates from the original fit: % pd1 = ProbDistUnivParam('normal',[ 25.05957669526, 13.10365248779]) pd1 = fitdist(arg_1, 'normal'); YPlot = pdf(pd1,XGrid); hLine = plot(XGrid,YPlot,'Color',[1 0 0],... 'LineStyle','-', 'LineWidth',2,... 'Marker','none', 'MarkerSize',6); LegHandles(end+1) = hLine; LegText{end+1} = 'Distribution for 5% blend'; % --- Create fit "Distribution for 10% blend" % Fit this distribution to get parameter values % To use parameter estimates from the original fit: % pd2 = ProbDistUnivParam('normal',[ 26.52834301884, 14.19758188303]) pd2 = fitdist(arg_2, 'normal'); YPlot = pdf(pd2,XGrid); hLine = plot(XGrid,YPlot,'Color',[0 0 1],... 'LineStyle','-', 'LineWidth',2,... 'Marker','none', 'MarkerSize',6); LegHandles(end+1) = hLine; LegText{end+1} = 'Distribution for 10% blend'; % --- Create fit "Distribution for 15% blend" % Fit this distribution to get parameter values % To use parameter estimates from the original fit: % pd3 = ProbDistUnivParam('normal',[ 49.48187814141, 43.9736557403]) pd3 = fitdist(arg_3, 'normal'); YPlot = pdf(pd3,XGrid); hLine = plot(XGrid,YPlot,'Color',[0.666667 0.333333 0],... 'LineStyle','-', 'LineWidth',2,... 'Marker','none', 'MarkerSize',6); LegHandles(end+1) = hLine; LegText{end+1} = 'Distribution for 15% blend'; % --- Create fit "Distribution for 30% blend" % Fit this distribution to get parameter values % To use parameter estimates from the original fit: % pd4 = ProbDistUnivParam('normal',[ 36.99158836968, 42.50386982451]) pd4 = fitdist(arg_4, 'normal'); YPlot = pdf(pd4,XGrid); hLine = plot(XGrid,YPlot,'Color',[0.333333 0.333333 0.333333],... 'LineStyle','-', 'LineWidth',2,... 'Marker','none', 'MarkerSize',6); LegHandles(end+1) = hLine; LegText{end+1} = 'Distribution for 30% blend'; % Adjust figure box on; hold off; % Create legend from accumulated handles and labels hLegend = legend(LegHandles,LegText,'Orientation', 'vertical', 'FontSize', 9, 'Location', 'northeast'); set(hLegend,'Interpreter','none');