Why is my plot() not working?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Star Strider
le 21 Fév 2022
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 commentaires
Star Strider
le 21 Fév 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Voir également
Catégories
En savoir plus sur Stress and Strain dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
