Why am I getting this error?
이전 댓글 표시
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)
답변 (2개)
Dyuman Joshi
2023년 11월 20일
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
AStudent
2023년 11월 20일
Dyuman Joshi
2023년 11월 20일
Could you please share the description and any related information of the problem you are trying to solve?
AStudent
2023년 11월 20일
Image Analyst
2023년 11월 20일
0 개 추천
See the FAQ for a thorough discussion:
카테고리
도움말 센터 및 File Exchange에서 Conway's Game of Life에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

