clear;clc;% User enter the corresponding values
E=input('Enter the value of Young Modulus E(Pa):')I=input('Enter the value of Moment of Inertia I(m^4):')w=input('Enter the value of uniform distributed load w(k N/m):')a=input('Enter the value of a(m):')L=input('Enter the value of total length of beam L(m):')Va= ((w)*(L-a))-((w)*(a)); %To calculate the force at fixed support
Ma= (((w)*(L-a)*((L-a)/2))-((w)*(a)*((L-a)+(a/2)))-((Va)*(L))); %To calculate the moment at fixed support
for x=1:0.1:L %To calculate the slope and deflection of beam AB from x=0 to x=total length of beam AB
fprintf("\nWhen x=%.1f", x) if (x-a)<0 slope= (1000/(E*I))*((Ma*x)+((Va/2)*(x^2))+((w/6)*(x^3))); %To calculate the slope of beam
fprintf("\nThe slope of beam AB is %.5frad", slope) deflection= (1000/(E*I))*(((Ma/2)*(x^2))+((Va/6)*(x^3))+((w/24)*(x^4))); %To calculate the deflection of beam
fprintf ("\nThe deflection of beam AB is %.5fm\n", deflection) else slope= (1000/(E*I))*((Ma*x)+((Va/2)*(x^2))+((w/6)*(x^3))-((w/3)*((x-a)^3))); %To calculate the slope of beam fprintf("\nThe slope of beam AB is %.5frad", slope) deflection= (1000/(E*I))*(((Ma/2)*(x^2))+((Va/6)*(x^3))+((w/24)*(x^4))-((w/12)*(((x-a)^4)))); %To calculate the deflection of beam fprintf ("\nThe deflection of beam AB is %.5fm\n", deflection) endendplot(x,slope)plot(x,deflection)
MATLAB: Error in plotting slope and deflection graph
graph
Best Answer