% The enclosed loops and changing yield force demonstrate path dependence.
% The figure remains in MATLAB and is not saved to disk.
figure("Color", "w", 'Position', [100, 200, 800, 800]);
tiledlayout(2, 1, "TileSpacing", "compact");
nexttile;
plot(targetDisplacement, matlabForce, "-", 'LineWidth', 2, ...
"DisplayName", "MATLAB callback");
hold on;
plot(deformation, force, "--", "MarkerSize", 5, 'LineWidth', 2,...
"DisplayName", "OpenSees");
grid on;
xlabel("Material deformation");
ylabel("Material force");
title("Elastoplastic MatlabUniaxialMaterial hysteresis");
legend("Location", "best");
nexttile;
h1 = stairs(0:numberOfSteps, matlabTangent, "-", 'LineWidth', 2, ...
"DisplayName", "MATLAB callback");
hold on;
h2 = plot(0:numberOfSteps, tangent, "--", "MarkerSize", 3, 'LineWidth', 2, ...
"DisplayName", "OpenSees");
yline(E, "--", "Elastic tangent");
yline(plasticTangent, "--", "Plastic tangent");
grid on;
xlabel("Committed analysis step");
ylabel("Algorithmic tangent");
legend([h1 h2], "Location", "best");
title("Tangent supplied to the OpenSees Newton algorithm");