Operation Order and Matrix Agreement Not working
1 次查看(过去 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 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!