How to find an intersection between two lines on a plot?

3 views (last 30 days)
I have this code,
for P = [0; 1000; 2000; 6000; 10000; 12000; 12900; 13400; 13600; 13800; 14000; 14400; 15200; 16800; 18400; 20000; 22400];
Elon = [0; 0.0002; 0.0006; 0.0019; 0.0033; 0.0039; 0.0043; 0.0047; 0.0054; 0.0063; 0.0090; 0.0102; 0.0130; 0.0230; 0.0336; 0.0507; 0.1108];
d = 0.505;
r = d/2;
Area = pi*r^2;
GL = 2;
Stress = P/Area
Strain = Elon/GL
plot(Strain,Stress,'-x')
axis([0 0.06 0 120000]);
grid;
grid minor;
title('Stress vs. Strain')
xlabel('Strain')
ylabel('Stress, psi')
hold on;
text(0.00195,5.991e+04,'\leftarrow Proportional limit');
Proprtinal_limit = Stress(6)
E = (Stress(6)-Stress(1))./(Strain(6)-Strain(1))
refline(E,-30724)
axis([0 0.06 0 120000]);
end
I need to find the X and Y coordinates for the intersection of "Plot" and "refline".

Accepted Answer

Star Strider
Star Strider on 7 Sep 2019
Try this:
RL = Strain*E -30724; % ‘refline’ As Funciton Of ‘Strain’
D = RL - Stress; % Difference
[Du,ix] = unique(D, 'stable'); % Unique ‘D’ & Indices
IntsctX = interp1(D(ix), Strain(ix), 0) % Value Of ‘Strain’ At Intersection
IntsctY = E*IntsctX - 30724 % Value Of ‘Stress’ At Intersection
producing:
IntsctX =
0.00324479065349119
IntsctY =
68968.0850755092

More Answers (0)

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!