Why am I getting this error?
Mostrar comentarios más antiguos
L = 2;
W = 2;
Ra = (W*L*(1/2));
Ma = (W*(L+L*(2/3)));
x_true = linspace (0,2*L,51);
v = ones(1,length(x_true));
m = ones(1,length(x_true));
for a = 1: (length(x_true))
x = x_true(a);
if x<=L
v(a) = Ra;
m(a) = Ra*x - Ma;
elseif x<=(3/2)*L
v(a) = Ra - (((x-L)*(x-L))/2);
m(a) = Ra*(x-L) - (((x-2)^3)/6) - Ma;
else
v(a) = Ra - (x-L)*(2*L-x) + (((2*L-x)*(W-(x-L)))/2);
m(a) = -Ma + Ra(2*L-x) - ((x-L)*(2*L-x) + (((2*L-x)*(W-(x-L)))/2))*(((2*L-x)*(W + 2*x - L))/(3*(W + x - L)));
end
end
plot (x_true,v,'r');
title('Shear Force Diagram');
xlabel('Beam Length(m)');
ylabel('Shear (N)');
xlim ([0 2.5*L])
xticks ([0 1*L 1.5*L 2.5*L])
grid on
plot (x_true,m,'b');
title('Bending Moment Diagram');
xlabel('Beam Length(m)');
ylabel('Moment (N-m)');
xlim ([0 2.5*L])
xticks ([0 1*L 1.5*L 2.5*L])
grid on
Beam_Length=x_true.';
Shear=v.';
Bending_Moment=m.';
Shear_Moment_table=table(Beam_Length,Shear,Bending_Moment);
display(Ma)
display(Ra)
Respuestas (2)
Dyuman Joshi
el 20 de Nov. de 2023
There is a missing operator between Ra and (2*L-x) in the else statement block -
Update the code accordingly.
%% vvvvvvvv
m(a) = -Ma + Ra(2*L-x) - ((x-L)*(2*L-x) + (((2*L-x)*(W-(x-L)))/2))*(((2*L-x)*(W + 2*x - L))/(3*(W + x - L)));
Also, it would be better to defined the number of points used to define the variable x_true by linspace() and use that variable instead of calling length() everytime.
3 comentarios
AStudent
el 20 de Nov. de 2023
Dyuman Joshi
el 20 de Nov. de 2023
Could you please share the description and any related information of the problem you are trying to solve?
AStudent
el 20 de Nov. de 2023
Image Analyst
el 20 de Nov. de 2023
0 votos
See the FAQ for a thorough discussion:
Categorías
Más información sobre Conway's Game of Life en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

