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!

