My homework assignment involves graphing the deflection equation of a beam. I am fairly new to matlab and i am coming across an error in how i am writing the codes since i am not using matrices
Here is my code and i get this error when ran
??? Subscript indices must either be real positive integers or logicals.Error in ==> inertia at 38U(x)= F./E.*I.*(x.^3-3.*L.*x.^2);E = input('Youngs Modulus:');r = input('Enter 1 for circular cross section, Enter 2 for rectangular cross section') ;if(r==1) d = input('Dimater:'); I = (pi*(d/2)^4)/4; elseif(r==2) b = input('Width of Beam:'); h = input('Height of Beam:'); I = (b*h^3)/12;end%Above runs how to find the I of cross section this will be used for figure
%1 and 2
%now need to create code to input the length of beam and where loads can be
%like element stiffness matrix
L = input('Length of beam:');F = input('Force');j = input('Enter 1 if force is at end of beam, Enter 2 if force is in middle of beam') ;if (j==1) w = F*L^2/3*E*I ; %this give max deflection
elseif (j==2) a = input('Location from support of point'); w = F*a^2/6*E*I*(a-3*l);end%above found the max deflection for the two different cases, now code needs
%to be written so i can graphically show these inputs i also need to add in
%how to see the values
%here right formula for graph and take values from above to plot it
%using equation for elastic curve
str=['deflection: ', num2str(w)];disp(str)x= 0:0.1:L;U(x)= F./E.*I.*(x.^3-3.*L.*x.^2);y = 0:U(x):w;plot(x,y)
Best Answer