How can I add a few extra things in my Graph?
9 views (last 30 days)
Show older comments
How can i get my matlab code to give me a graph with A B C and D as shown in the image. My code so far is also posted. I will also like to add a dashed line with the 6% offset. I do not know how to do these two things.
close all
clear all
clc
% The data show wer obatined from a tensile test of high=strenght stell.
% The test specimen had a diameter of 0.505 in and a gage lenth of 2.00
% in. elongation between the gage marks was 0.12 in and the minimum
% diameter was 0.42.
% Plot the conventional stress-strain curve for the steel and determine the
% propotional modulus of elasticity, yield stress at 0.1% offset, ultimate
% stress, percent elongation is 2.00 in., and percent reduction in area.
% l = load in lbs e = elongation in inches d = diameter A = area S = Stress
% L = initial lenth E = strain in elongation p = percentage of elongation
% r = reduction in area k = elasticity
l = [1000 2000 6000 10000 12000 12900 13400 13600 13800 14000 14400 15200 16800 18400 20000 22400];
e = [.0002 .0006 .0019 .0033 .0039 .0043 .0047 .0054 .0063 .0090 .0102 .0130 .0230 .0336 .0507 .1108];
d = 0.505;
L = 2;
A = (pi*d^2)/4;
S = l/A;
E = e/L;
plot (E,S)
grid on
hold on
xlabel('Strain')
ylabel('Stress')
title('Stress-Strain Diagram')
hold off
%Propotional limit comes out to 65000 psi
%Yield stress = 68897.88 psi
%Ultimate stress = 112832.76 psi
k = 49926/1.65*10^-3 %Comes out in psi of the modulus of elasticity
p = (.12/2)*100 %comes out in percent of elongation of the speciemen
r = ((.2-.138)/.2)*100 %comes out in percent of area
0 Comments
Accepted Answer
Simon Chan
on 1 Feb 2022
Edited: Simon Chan
on 3 Feb 2022
You may use function text to insert text on the figure.
You may define the text position better by assigning the position manually.
Edit for correction of the offset line:
Use 0.1% mentioned in the text inside your code instead of 6% which may not be practical. Anyway, you may adjust on the following code
plot(E,S);
grid on
hold on
xlabel('Strain')
ylabel('Stress')
title('Stress-Strain Diagram')
textname = {'A','B','C','D'};
pointA = 65000;
pointB = 68897.88;
pointC = 68897.88;
pointD = 112832.76;
pointAll = [pointA,pointB,pointC,pointD];
for k = 1:4
xpos = E(S<pointAll(k));
if k<3
offset = -0.002;
else
offset = 0.002;
end
text(xpos(end)+offset,pointAll(k),textname{k},'FontSize',14,'FontAngle','italic');
end
%% Proportional Region (Region yield stress at 0.1% offset)
%
%
idx.proportional = sum(S<pointA); % Index for proportional region
slope = (S(idx.proportional)-S(1))/(E(idx.proportional)-E(1)); % Calculate slope
new_E = E + 0.001; % Adding offset for strain
new_S = slope*E; % New stress for same slope
idx.plot = new_S<pointD; % Limit the plot for stress below maximum stress
plot(new_E(idx.plot),new_S(idx.plot),'r--'); % Plot the offset line
hold off
0 Comments
More Answers (0)
See Also
Categories
Find more on Stress and Strain in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!