Clear Filters
Clear Filters

(Strain vs Stress Curve) to (Stress Vs Strain Curve) Switch My X-axis into Y-axis in my plot

7 views (last 30 days)
I plotted a strain- stress curve graph however, in physical materials studies stress(y-axis)-strain(x-axis) curve is the convention in plotting. I have tried to change the graph axis but to just recive a blank plot. I have tried everything but to no avail. What am I doing wrong?
clc
clear all
close all
E1=4000; %4GPa written in 4000 MPa
E2=5000; %5GPa written in 5000 MPa
Mu= 1.2*10^5; %this measures creep
stress0.norm = 800; %this is initial stress value is in MPa
for i=1:stress0.norm
strain.normal(i)=i/E1; % This is storing the values before yielding
end
for i=stress0.norm:1500 %this is the finising stress in MPa (after yielding
strain.normal(i)=(i/E1)+((i-stress0.norm)/E2); % This is storing the values after yielding
end
% The graph with what I started off
figure ('Name', 'Linear Hardening Model', 'NumberTitle', 'off')
plot (strain.normal,'b');
hold on
plot (800,.2, 'rx', 'LineWidth', 2);
% plot (strain.normal,'b');
title ('Linear Hardening Model E2 +/- 10%');
xticks(0:100:1500);
xlabel('stress(in MPa)');
ylabel('strain');
grid on
legend('Normal','Yielding Location','Location','NorthEast')
% What I wanted to achieve but get a blank graph
figure ('Name', 'Linear Hardening Models Issue ', 'NumberTitle', 'off')
plot (strain.normal,length(strain.normal),'b');
hold on
plot (.2,800,'rx', 'LineWidth', 2);
title ('Linear Hardening Model');
axis ([0 0.6 0 1500])
yticks(0:100:1500);
xticks
xlabel('strain');
ylabel('stress(in MPa)');
grid on
legend('Normal','Yielding Location','Location','NorthEast')

Accepted Answer

Tommy
Tommy on 15 Apr 2020
plot (strain.normal,length(strain.normal),'b');
In this line,
length(strain.normal)
is a scalar, so nothing is plotted, similar to
figure;plot(1:10,1)
Use this instead:
plot (strain.normal,1:length(strain.normal),'b');
  2 Comments
Pablo Tejada Jr.
Pablo Tejada Jr. on 15 Apr 2020
Wow this fixed the issue. Thank you so much Tommy for your time, I am truly grateful. I wanted to ask you a question:
  • wouldn't "1:length(strain.normal)" also be considered scalar?
  • what makes
length(strain.normal)
different to
1:length(strain.normal)
I ask you this becuase I would love to understand this concept. Thank you in advance for helping me become a better Engineer.
Tommy
Tommy on 15 Apr 2020
My pleasure!
It's the same as the difference between
>> 10
ans =
10
and
>> 1:10
ans =
1 2 3 4 5 6 7 8 9 10
The former is a scalar (size 1x1), the latter is a vector (size 1x10).

Sign in to comment.

More Answers (0)

Categories

Find more on Stress and Strain in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!