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

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".

 采纳的回答

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

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Stress and Strain 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by