# Need Help Plotting a Line Over Another Line

6 views (last 30 days)

Show older comments

Austin Milliren
on 10 Apr 2020

Answered: James Browne
on 10 Apr 2020

Hello all. I am trying to plot a Axial Stress-Strain Curve, which I've got no problem. But I am also trying to plot another line on the graph and am having issues. My main issue is that I don't quite know the equation for the line. I know that it starts at (0.002, 0) and has the same slope as the straight portion of stress strain curve but that's it. Basically it's a simplified way to find the "yield point" in a material from its stress strain graph, you start at 0.002 and draw a line parallel to the straight portion of the stress strain curve and where it intersects the curve is the strain point. So I need to plot the yield point line and find where it intersects the stress strain curve. I've coped my current code below that has the stress strain curve and any help getting the second line and the intersetion point would be greatly helpful and appreciated. Thanks!

P = [0 5 10 30 50 60 65 67 68 69 70 80 90 100 110 120]; %% Load (kN)

D = [0 0.0005 0.0015 0.0048 0.0084 0.0102 0.0109 0.0119 0.0137 0.0160 0.0229 0.0546 0.0965 0.1228 0.2814 0.3014]; %% Deformation (cm)

L = 5.08 / 10; %% Original lenght (meters)

A = pi * ((1.283 / 2) / 10) ^ 2; %% Area of the gauge

D1 = D ./ 10; %% Turn D into meters

P1 = P .* 1000; %% Turn Load into Newtons

G = P1 ./ A; %% Axial stress, Load / Area

S = D1 ./ L; %% Axial strain, Deformation / Original Length

plot(S, G, '-o')

title('Axial Stress-Strain');

xlabel('Axial Strain');

ylabel('Axial Stress');

##### 0 Comments

### Accepted Answer

James Browne
on 10 Apr 2020

Hi, I think I can at least point you in the right direction:

The first step is to get the equation for the linear portion of the stress strain curve. I did this by noting that the curve passes through the origin and then taking the last point in the linear portion of the curve from the graph:

Now we have two points from the line, (0,0) and (0.002146,5.028e6) and we also know that the x intercept is 0.002 so we can generate an equation for this line as follows:

m = dy/dx

m = (0-5.028e6)/(0-0.002146)

m = 2.3430e9

y = mx + b

b = y-(mx) Substituting x = 0.002 and y = 0

b = 0 - 2.3430e9*(0.002)

b = -4686000

y = 2.3430e9x - 4686000

m = dy/dx

= (0-5.028e6)/(0-0.002146)

= 2.3430e+09

Y = mx + b

b = y-(mx) Substituting in 0.002 for x and 5.028e6 for y:

b = 2.3430e+09*-0.002

b = -4686000

then the equation for the line that is roughly parallel to the roughly linear portion of the stress strain curve, in y = mx + b form is:

y = 2.3430e+09x - 4686000

Now, we modify the original code to plot this new line to see where it will intersect with the stress strain curve and zoom in on the intersection area...

P = [0 5 10 30 50 60 65 67 68 69 70 80 90 100 110 120]; %% Load (kN)

D = [0 0.0005 0.0015 0.0048 0.0084 0.0102 0.0109 0.0119 0.0137 0.0160 0.0229 0.0546 0.0965 0.1228 0.2814 0.3014]; %% Deformation (cm)

L = 5.08 / 10; %% Original lenght (meters)

A = pi * ((1.283 / 2) / 10) ^ 2; %% Area of the gauge

D1 = D ./ 10; %% Turn D into meters

P1 = P .* 1000; %% Turn Load into Newtons

G = P1 ./ A; %% Axial stress, Load / Area

S = D1 ./ L; %% Axial strain, Deformation / Original Length

y = 2.3430e+09*S - 4686000; %%line parallel to linear stress strain curve

plot(S, G, '-o',S,y,'-k')

ylim([0,1e7])

xlim([0,0.01])

title('Axial Stress-Strain');

xlabel('Axial Strain');

ylabel('Axial Stress');

Next, from the resulting plot, we grab a data point on either side of the intersection and use these points to create another new line in y = mx + b format...

m = dy/dx

m = (5.337e6-5.414e6)/(0.00315-0.004508)

m = 5.6701e+07

y2 = mx + b

b = y-(mx) substituting x = 0.00315, y = 5.337e6

b = 5.337e6 - 5.6701e+07*(0.00315)

b = 5.1584e6

y2 = 5.6701e7x + 5.1584e6

Next, we modify the code again with y2 shown, just to kae sure the equation is looks right:

P = [0 5 10 30 50 60 65 67 68 69 70 80 90 100 110 120]; %% Load (kN)

D = [0 0.0005 0.0015 0.0048 0.0084 0.0102 0.0109 0.0119 0.0137 0.0160 0.0229 0.0546 0.0965 0.1228 0.2814 0.3014]; %% Deformation (cm)

L = 5.08 / 10; %% Original lenght (meters)

A = pi * ((1.283 / 2) / 10) ^ 2; %% Area of the gauge

D1 = D ./ 10; %% Turn D into meters

P1 = P .* 1000; %% Turn Load into Newtons

G = P1 ./ A; %% Axial stress, Load / Area

S = D1 ./ L; %% Axial strain, Deformation / Original Length

y = 2.3430e+09*S - 4686000; %%line parallel to linear stress strain curve

y2 = 5.6701e7*S + 5.1584e6;

plot(S, G, '-o',S,y,'--k',S,y2,'--r')

ylim([0,1e7])

xlim([0,0.01])

title('Axial Stress-Strain');

xlabel('Axial Strain');

ylabel('Axial Stress');

legend('Stres Vs Strain','Linear Approx of Linear Stress Strain Curve','Linear approximation of SS Curve at intersection','location','southeast')

Everything looks good so now all we need to do is figure out where the lines y and y2 intersect and that will also be the point where y (the line that is parallel to the linear portion of the stress strain curve) intersects the stress strain curve...

To do this we modify the code again to use the fzero function to find the intersection, add that point to the plot. This is where it gets a little complicated but bear with me.

We will use the fzero function, info found here

This also requires the use of an anonymous function, info found here:

The anonymous function is required because fzero expects a function handle data type as its input...

Before all of that though, we have to get the equations arranged nicely for fzero. What fzero does is tries to find where the input equation is equal to a value that you give it so a trick that you can do is as follows:

We want to know where y = y2 but we only use one equation for fzero we create a new function:

f(x) = y - y2

We do this because, at the intersection of y and y2, they are both equal so y - y2 = 0. Now we can use fzero to find the intersection by telling fzero to look for the value of x where f(x) = 0 but we still need to make f(x) an anonymous function but that is easy, it looks like this:

fun = @(x) 2.3430e+09*x - 4686000 - 5.6701e7*x - 5.1584e6;

This will get us the value of x where y and y2 (and therefore also where y and the SS curve) intersect. The only thing left is to find the y-value where the intersection happens, we do that by substituing the x value into either y or y2 (since both functions are approximately equal at the intersection, we can use either one to find the y-value).

The code that I used to finish the job is as follows:

P = [0 5 10 30 50 60 65 67 68 69 70 80 90 100 110 120]; %% Load (kN)

L = 5.08 / 10; %% Original lenght (meters)

A = pi * ((1.283 / 2) / 10) ^ 2; %% Area of the gauge

D1 = D ./ 10; %% Turn D into meters

P1 = P .* 1000; %% Turn Load into Newtons

G = P1 ./ A; %% Axial stress, Load / Area

S = D1 ./ L; %% Axial strain, Deformation / Original Length

y = 2.3430e+09*S - 4686000; %%line parallel to linear stress strain curve

y2 = 5.6701e7*S + 5.1584e6; %%Linear approximation of the SS curve near the intersection

%Find the intersection of the two linear approximations

fun = @(x) 2.3430e+09*x - 4686000 - 5.6701e7*x - 5.1584e6;

InterceptX = fzero(fun,0);

%Find the y-value of the intersection by using the xintercept value into

%the equation for y

InterceptY = 2.3430e+09*InterceptX - 4686000;

plot(S, G, '-.',S,y,'--k',S,y2,'--r',InterceptX,InterceptY,'ko')

ylim([0,1e7])

xlim([0,0.01])

title('Axial Stress-Strain');

xlabel('Axial Strain');

ylabel('Axial Stress');

legend('Stres Vs Strain','Linear Approx of Linear Stress Strain Curve','Linear approximation of SS Curve at intersection','location','southeast')

I changed the markers on the SS curve to make the intersection point stand out. You can always change the marker properties of the intersection point to make it bigger and bolder but I didn't feel like going that route. The result should look something like this:

Hope that helps =)

##### 0 Comments

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!