Code runs but no graphical output
4 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
Walter Roberson
2023-12-1
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)'
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!