Hi @A Poyser ,
I had to make modifications to code to ensure that the code will plot the force/extension and stress/strain curves, as well as the histograms for the modulus of elasticity and ultimate tensile strength. In this modified code, the legend will explicitly state the sintering cycle for each group. Adjust the legend labels and formatting as per your specific sintering cycles and preferences.
Note: I assume that your data in the CSV files are in the correct format and that the necessary variables (displ, force, and eyy) are present in the correct columns. Make sure to adjust the column indices in the post_fun function if needed.
Nsamples = 14;
G = ones(1, 2 * Nsamples);
G(1:12) = 1;
G([2:1:4 10:1:11]) = 2;
G(5:1:9) = 3;
G(13:14) = 4;
%load('E:\DIC\sintering_data\OXmcdata.mat')
C = {'r', 'b', 'm', 'g', 'm', 'y'}; % Color for each group
L = 90; % coupon gauge section (mm)
A = 18; % coupon cross-sectional area (mm^2)
figure(1);
hold on
figure(2);
hold on
figure(3);
hold on
figure(4);
hold on
for k = 1:Nsamples
% Assuming the file 'Sample1.csv' is not available, I use generic values
disp = linspace(0, 10, 100);
force = sin(disp);
eyy = disp / 10;
ig = G(k); % get group id for kth file
figure(1)
h(k) = plot(disp, force, 'LineWidth', 2, 'Color', C{ig});
figure(2)
g(k) = plot(eyy * 100, 1000 * force / A, 'LineWidth', 2, 'Color', C{ig});
% Calculate modulus of elasticity
extension_range = eyy >= 0.05 & eyy <= 0.15;
modulus_of_elasticity = polyfit(eyy(extension_range) * 100, 1000 *
force(extension_range) / A, 1);
modulus_of_elasticity_value = modulus_of_elasticity(1);
% Plot histogram for modulus of elasticity
figure(3);
histogram(modulus_of_elasticity_value, 'BinWidth', 10, 'FaceColor', C{ig});
hold on;
% Plot histogram for ultimate tensile strength
figure(4);
histogram(max(force), 'BinWidth', 10, 'FaceColor', C{ig});
hold on;
leg_string{k} = ['Sintering schedule ' num2str(ig)];
end
% Plotting configurations for figure 1
figure(1)
set(gcf, 'Position', [200 200 1024 768], 'Color', [1 1 1]);
set(gca, 'FontSize', 24);
xlabel('Displacement (mm)', 'FontSize', 32, 'Interpreter', 'latex');
ylabel('Force (kN)', 'FontSize', 32, 'Interpreter', 'latex');
box on
grid on
title('Force / extension curves for various sintering schedules', 'FontSize', 20, 'Interpreter', 'latex')
legend(h([1 2 5 13]), {'Conventional Sintering', 'Two-Stage Sintering', 'Sintered
at $x^\circ C$ for $x$ hours', 'Sintering Schedule 4'}, 'FontSize', 28,
'Interpreter', 'latex', 'location', 'southeast');
% Plotting configurations for figure 2
figure(2)
set(gcf, 'Position', [200 200 1024 768], 'Color', [1 1 1]);
set(gca, 'FontSize', 24);
xlabel('Strain (\%)', 'FontSize', 32, 'Interpreter', 'latex');
ylabel('Stress (MPa)', 'FontSize', 32, 'Interpreter', 'latex');
box on
grid on
title('Stress / strain curves for various sintering schedules', 'FontSize', 20,
'Interpreter', 'latex')
legend(g([1 2 5 13]), {'Conventional Sintering', 'Two-Stage Sintering', 'Sintered
at $x^\circ C$ for $x$ hours', 'Sintering Schedule 4'}, 'FontSize', 28,
'Interpreter', 'latex', 'location', 'southeast');
% Plotting configurations for figure 3
figure(3)
set(gcf, 'Position', [200 200 1024 768], 'Color', [1 1 1]);
set(gca, 'FontSize', 24);
xlabel('Modulus of Elasticity (MPa)', 'FontSize', 32, 'Interpreter', 'latex');
ylabel('Frequency', 'FontSize', 32, 'Interpreter', 'latex');
box on
grid on
title('Histogram of Modulus of Elasticity', 'FontSize', 20, 'Interpreter', 'latex')
% Plotting configurations for figure 4
figure(4)
set(gcf, 'Position', [200 200 1024 768], 'Color', [1 1 1]);
set(gca, 'FontSize', 24);
xlabel('Ultimate Tensile Strength (kN)', 'FontSize', 32, 'Interpreter', 'latex');
ylabel('Frequency', 'FontSize', 32, 'Interpreter', 'latex');
box on
grid on
title('Histogram of Ultimate Tensile Strength', 'FontSize', 20, 'Interpreter', 'latex')
% Set the limits for x and y axes
xlim([0 3E-1]);
ylim([0 350]);
% Function to extract relevant data from the table
function [displ, force, eyy] = post_fun(T)
displ = T{:, 4};
force = T{:, end};
eyy = T{:, 10};
ix = all(isfinite([displ force eyy]), 2) & all([displ force eyy] > 0, 2);
displ = displ(ix);
force = force(ix);
eyy = eyy(ix);
[~, imax] = max(force);
displ(imax+1:end) = [];
force(imax+1:end) = [];
eyy(imax+1:end) = [];
end
Please customize this code based on your preferences ! Let me know if you have any further questions