首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用Matlab绘制悬臂梁图

用Matlab绘制悬臂梁图
EN

Stack Overflow用户
提问于 2017-11-22 04:15:19
回答 1查看 1.5K关注 0票数 1

问题

我必须用Matlab绘制一个梁/悬臂。我的意见如下:

  • 梁长
  • 负载的位置(输入是一个向量)
  • 负载的力(输入是一个向量)
  • 不管是悬臂还是非悬臂。因为我有不同的方程来计算位移。

我的解决方案

我想出了一个关于如何绘制悬臂梁的想法,但我不能用MATLAB把它写成代码。我花了几个小时试图在Matlab上写一些东西,但是我没有得到任何结果。(我是Matlab的新手)

我的解决方案如下:我有从开始位置的位移公式。

我可以为x坐标定义一个向量,直到给定的光束长度。因此,x=0 .我

然后,我想要定义另一个向量,其中的差异是计算(这是我无法计算出Matlab)

Y= h,h- y(x1),h- y(x2),……H- y(L)

其中h是起始高度,我认为它被定义为(y(x1) - y(L)) + 1,这样图就不会进入负轴。y(x)是计算梁的位移或下落的函数。

一旦完成,我可以简单地绘制(x,y),这将给我一个形状的偏转梁的形状,在给定的范围从0到光束长度。我已经在excel上测试了我的理论,它的工作原理与图表有关,但我无法在Matlab上找到实现方法。

我的不完整代码

代码语言:javascript
复制
%Firstly we need the inputs

%Length of the beam
l = str2double(input('Insert the length of your beam: ', 's'));

%Now we need a vector for the positions of the load
a = [];
while 1
    a(end+1) = input('Input the coordinate for the position of your load: ');
    if length(a)>1; break; end
end

%Now we need a vector for the forces of the load
W = [];
while 1
    W(end+1) = input('Input the forces of your load: ');
    if length(W)>1; break; end
end

%
%
%
%Define the formula
y = ((W * (l - a) * x)/(6*E*I*l)) * (l^2 - x^2 - (l - a)^2);

%Where
E = 200*10^9;
I = 0.001;

%
%
%

%Now we try to plot
%Define a vector with the x values
vectx = [];
for i = 1:l
    vectx = [vectx i];
end

%Now I want to calculate displacement for each x value from vectx
vecty = [];
for i=1:l
    vecty=[10 - y(x(i)) i];
end

%Now I can plot all the information
plot(vectx, vecty)
hold on

%Now I plot the coordinate of the positions of the load
plot(load)
end

确实需要一些帮助/指导。如果有人能帮我,或者给我一个提示,我会非常感激的:)

我编辑了这个问题还有更多的细节

EN

回答 1

Stack Overflow用户

发布于 2017-11-23 08:49:45

在您的示例中,有几件事情不起作用。例如,参数应该在使用它们之前定义,所以E和I应该在挠度方程之前定义。你应该定义x,如果你在length(a)>1;上停止输入,我不明白你为什么把输入放在while循环中。你可以移除循环。你不需要一个循环来计算位移,你只需要在向量之间使用一个子运算,比如displacement = 10 - y。但是,我不明白在你的例子中H是什么,因为你的光束最初处于0位置,你的位移就是-y。最后,你计算变形形状的公式是错误的,它只代表了梁的第一部分。

在这里,如果此代码有效,请试一试:

代码语言:javascript
复制
%Length of the beam
l = input('Insert the length of your beam: ');

%Now we need a vector for the positions of the load
a = input('Input the coordinate for the position of your load: ');

%Now we need a vector for the forces of the load
W = input('Input the forces of your load: ');


%Define the formula
E = 200*10^9;
I = 0.001;
% x Position along the beam
x = linspace(0,l,100);

b = l - a;
% Deflection before the load position
pos = x <= a;
y(pos) = ((W * b .* x(pos))/(6*E*I*l)) .* (l^2 - x(pos).^2 - b^2);

% Cantilever option
% y(pos) = W*x(pos).^2/(6*E*I).*(3*a-x(pos));


% Deflection after the load position
pos = x > a;
y(pos) = ((W * b )/(6*E*I*l)) .* (l/b*(x(pos)-a).^3 + (l^2 - b^2)*x(pos) - x(pos).^3);
% Cantilever option
% y(pos) = W*a^2/(6*E*I).*(3*x(pos)-a);

displacement = 10 - y;  % ???


% Plot beam
figure
plot(x , x .* 0 , 'k-')
hold on;

% Plot deflection
plot(x , y , '--')

% Plot load position
% Normalize arrow size as 1/10 of the beam length
quiver(a , 0 , 0 , sign(W) .* max(abs(y))/2)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47426696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档