how to find the max deflection and its position in a beam
Show older comments
function [y,xMax,yMax]=beamDeflection(L,w,I,E)
k=200;
a=L/4;
y=zeros(1,k);
i=1:k;
x(i)=linspace(0,L,k);
for i=1:k;
if x(i)<=a;
y=((-w*(L-a)^2)/(6*E*I))*(3*(L)-(3*x(i))*(L-a));
else
y=(((-w)*(L-x(i))^2)/(6*E*I))*(3*(L-a)-(L)+(x(i)));
end
end
for i=1:k
yMax=max(y);
xMax=find(max(y));
I am trying to find the max deflection and its position. I tried running the program without finding the location of the max deflection and I am getting a value of 0 which is wrong. I am getting an error when I am trying to find the location of the max deflection. Any suggestions about how I can change my code to get the right answer.
2 Comments
John D'Errico
on 5 Mar 2016
Edited: John D'Errico
on 5 Mar 2016
When you post code, select the code block, then click on the "{} Code" button. Otherwise it becomes an unreadable mess. I fixed it for you, this once.
Walter Roberson
on 6 Mar 2016
Duplicates http://uk.mathworks.com/matlabcentral/answers/271645-how-to-find-the-max-deflection-in-the-beam-and-position-of-the-max-deflection which also has an Answer.
Answers (1)
John D'Errico
on 5 Mar 2016
To answer your question, I presume that the maximum deflection is actually a negative value. So why not compute the maximum of the absolute value of the deflection? What does this yield?
max(abs(deflection))
By the way, you don't need to use find AFTER the max call. Just use max properly.
x = rand(1,5)
x =
0.29019 0.1838 0.42764 0.8635 0.036295
Clearly the maximum element was the 4th one.
[M,ind] = max(x)
M =
0.8635
ind =
4
Categories
Find more on Simscape Multibody in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!