Why is my plot() not working?
17 次查看(过去 30 天)
显示 更早的评论
Hello! I'm fairly new to MATLAB and I'm tryng out a simple code which should help me plot a stress-strain curve using user-input values. However, my plot() isn't appearing. Should I add or remove something from the code?
% User-input values for Strain
initial_l = input('Enter the initial length of the material in m: ');
change_l = input('Enter the elongation of the material in m: ');
% User-input values for Stress
load = input('Enter the load exerted on the material in N: ');
rad = input('Enter the radius of the material in m: ');
% Formulas for Strain
del_l = change_l - initial_l;
strain_x = change_l./ initial_l;
% Formulas for Stress
area = pi*rad^2;
stress_y = load./ area;
% Plotting of values
figure(1) % Stress-Strain Curve
plot(strain_x,stress_y)
x = strain_x;
y = stress_y;
xlabel('Strain')
ylabel('Stress')
hold on
grid on
axis([-1 1 -0.01 0.01])

0 个评论
回答(1 个)
Star Strider
2022-2-21
Experiment by commenting-out the axis call.
The values being plotted are outside the axes limits.
initial_l = 20;
change_l = 30;
load = 40;
rad = 50;
% Formulas for Strain
del_l = change_l - initial_l;
strain_x = change_l./ initial_l;
% Formulas for Stress
area = pi*rad^2;
stress_y = load./ area;
% Plotting of values
figure(1) % Stress-Strain Curve
plot(strain_x,stress_y, '-p')
x = strain_x;
y = stress_y;
xlabel('Strain')
ylabel('Stress')
hold on
grid on
% axis([-1 1 -0.01 0.01])
.
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stress and Strain 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
