Operation Order and Matrix Agreement Not working
2 ビュー (過去 30 日間)
古いコメントを表示
This code will not run with the error "inner matrix dimensions must agree".I am not sure is the fomulas are written out completely. This utilizes the Deflection equations found here (It is a pdf of multiple deflection equations):
I used the formulas on: 2, 3, 7, 8
I is the moment of Inertia L is the actual Length of the beam b is the width of the beam x is the points to test on a beam // this is saved a a vector 0 is omega which is the Force(Magnitude) divided by the Length of the beam
Please help if you can understand this or know what is wrong.
I = z.Inertia;
L = z.Length;
b = z.Width;
x = linspace(0,z.Length);
o = z.Magnitude/z.Length; % Magnitude is them same as the force
if z.Load == 1
if z.Support == 1
Beam.y1 = (F*x.^2/6*E*I)*(3*a-x); % 0<x<a
Beam.y2 = (F*a^2/6*E*I)*(3*x-a); % a<x<L
else % x.Support == 2
Beam.y1 = (F*b*x/6*L*E*I)*(L^2-x.^2-b^2); % 0<x<a
Beam.y2 = (F*b/6*E*L*I)*((L/b)*(x-a)^3+(L^2-b^2)*x-x.^3); % a<x<L
end
else % x.Load == 2
if z.Support == 1
Beam.y1 = (o*x.^2/24*E*I)*(x.^2+6*L^2-4*L*x);
else % x.Support == 2
Beam.y1 = (o*x.^2/24*E*I)*((L^3-2*L*x.^2)+x.^3);
end
end
0 件のコメント
採用された回答
Walter Roberson
2012 年 11 月 30 日
Several parts of your code have expressions of the general form
f(x) * g(x)
where x is a row vector and f and g transform row vectors to row vectors. Therefore the multiplication you are requesting by the "*" operator is matrix multiplication between two row vectors. Matrix multiplication requires columns to match with rows, not rows to match with rows.
What you probably want is the .* operator
f(x) .* g(x)
which does element-by-element multiplication.
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Accelerators & Beams についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!