Effacer les filtres
Effacer les filtres

Code runs but no graphical output

2 vues (au cours des 30 derniers jours)
Peter Bohlen
Peter Bohlen le 1 Déc 2023
Commenté : Peter Bohlen le 1 Déc 2023
I am trying to plot the deflection of a beam using MATLAB. My code runs but there is no output on my graph. I am using "for" operation rather than an array, because the array was producing errors. The code is as follows:
E = 200000; % Young's Modulus in N/mm^2
I = 416.667; % Moment on Inertia in mm^2
P = 600; %Applied force in N
Q = 1200; %Applied force in N
L = 3000; %Length of Beam in mm
b = 1000; %Applied location in mm for 600 N
a = 2000; %Applied location in mm for 1200 N
for x=0:10:3000
V = ((-P * b .* x) / (6 * E * I * L)) * (L^2 - b^2 - x.^2) + (((-Q * a .* x) / (6 * E * I * L)) * (L^2 - a^2 - x.^2));
end
plot (V,x)
xlabel 'Distance (mm)'
ylabel '(Deflection mm)'
I have attached a picture of the graph as well as the MATLAB script. Any assistance would be much appreciated!

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Déc 2023
E = 200000; % Young's Modulus in N/mm^2
I = 416.667; % Moment on Inertia in mm^2
P = 600; %Applied force in N
Q = 1200; %Applied force in N
L = 3000; %Length of Beam in mm
b = 1000; %Applied location in mm for 600 N
a = 2000; %Applied location in mm for 1200 N
xvals = 0:10:3000;
num_x = length(xvals);
for xidx = 1 : num_x
x = xvals(xidx);
V(xidx) = ((-P * b .* x) / (6 * E * I * L)) * (L^2 - b^2 - x.^2) + (((-Q * a .* x) / (6 * E * I * L)) * (L^2 - a^2 - x.^2));
end
plot (xvals, V)
xlabel 'Distance (mm)'
ylabel '(Deflection mm)'
  1 commentaire
Peter Bohlen
Peter Bohlen le 1 Déc 2023
Thank you!! Looks like I did not set up the "for" loop correctly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by