# Displacement of cantilevered beam matlab

• DODGEVIPER13
In summary, the conversation discusses writing a Matlab function to plot the displacement of a cantilevered beam under a point load. The function should also report the maximum deflection and angle at the tip of the beam. The formulas for the displacement and tip angle are provided, along with a sample test using specific values. The attempted solution is also shown, but the plot does not appear. In order to fix this, the value for E should be changed to 30,000,000 psi.
DODGEVIPER13

## Homework Statement

Write a Matlab function to plot the displacement of a cantilevered beam under a point load. Annotate the figure’s axes and title the figure. In addition to creating the plot, the function should report (in the figure’s title!) the maximum deflection and angle between the horizontal and the surface of the beam at its tip. The geometry of the beam is shown below:
The formulas for the displacement y and tip angle θ are
y=-((Wx^2)/6EI)(3a-x) for 0<X<a
y=-((Wa^2)/6EI)(3x-a) for a<x<L
theta=0.5*((Wa^2)/EI)

where W is the point load, E is the Young’s modulus for the beam, I is the moment of inertia for the beam, and L is the length of the beam. Test your function with E = 30 Mpsi, I = 0.163 in4, L = 10 in, a = 3 in, W = 1,000 lbf. Report both your code and the plot for the given values.

## The Attempt at a Solution

function[ymax,theta]=displacement(E,I,L,a,W)

for x=linspace(0,a);
y=-(W*x.^2*(3*a-x))/(6*E*I);
end
for x=linspace(a,L);
y=-(W*a.^2*(3*x-a))/(6*E*I);
end

theta=0.5*((W*a.^2)/(E*I));
plot(y,x);
xlabel('Pos');
ylabel('disp');
title(sprintf('ymax=%g, theta=%5.3f',ymax,theta));

This is what I get:

ans =

8.2822e+003

The plot shows nothing so I am confused, what should I do?

#### Attachments

• Capture.PNG
14 KB · Views: 823
For one thing, E = 30 Mpsi = 30 * 10^6 psi, or 30,000,000 psi. This accounts for the discrepancy in the deflection calculation. It doesn't explain why to slope wasn't output.

>> displacement(30*10.^6,0.163,10,3,1000) ok this is what I entered and I still didn't get a plot any more hints?

hey appreciate the help man I got it figure out

Your attempt at a solution is on the right track, but there are a few things that need to be corrected in order for your code to work correctly. First, you need to define your variables and constants, such as E, I, L, a, and W. Without these values, your code won't be able to calculate the displacement and angle correctly. Also, your code currently only calculates the displacement at a single point, rather than along the entire length of the beam. You need to use a loop to calculate the displacement at multiple points along the beam's length.

Additionally, your code for the second part of the beam (x > a) is incorrect. It should be y=-(W*a^2*(3*x-a))/(6*E*I), without the dot after the "a". This is causing an error in your code.

Here is a corrected version of your code:

% Define variables and constants
E = 30*10^6; % Young's modulus in psi
I = 0.163; % moment of inertia in in^4
L = 10; % length of beam in inches
a = 3; % distance from support to point load in inches
W = 1000; % point load in lbf

% Define arrays for x and y values
x = linspace(0,L); % create an array of x values from 0 to L
y = zeros(size(x)); % create an array of the same size as x, filled with zeros

% Calculate displacement at each point along the beam's length
for i = 1:length(x)
if x(i) <= a % for x values less than or equal to a, use first formula
y(i) = -(W*x(i)^2*(3*a-x(i)))/(6*E*I);
else % for x values greater than a, use second formula
y(i) = -(W*a^2*(3*x(i)-a))/(6*E*I);
end
end

% Calculate maximum displacement and angle
ymax = max(y); % maximum displacement is the largest value in the y array
theta = 0.5*((W*a^2)/(E*I)); % angle in radians

% Plot displacement vs. position
plot(x,y);
xlabel('Position (in)');
ylabel('Displacement (in)');
title(sprintf('Maximum displacement = %g in, Angle = %5

## 1. What is a cantilevered beam?

A cantilevered beam is a type of structural element that is supported at one end and free to move at the other end. It is commonly used in engineering and architecture to support structures such as bridges, balconies, and roofs.

## 2. How is the displacement of a cantilevered beam calculated?

The displacement of a cantilevered beam can be calculated using the principles of structural mechanics, specifically the equations of static equilibrium. In MATLAB, the displacement can be calculated by applying the boundary conditions and solving for the unknown displacement using the governing equations.

## 3. What factors affect the displacement of a cantilevered beam?

The displacement of a cantilevered beam is influenced by several factors, including the material properties of the beam, the length and cross-sectional area of the beam, the magnitude and direction of the applied load, and the boundary conditions at the fixed end of the beam.

## 4. Can MATLAB be used to analyze the displacement of a cantilevered beam?

Yes, MATLAB is a powerful tool for analyzing the displacement of a cantilevered beam. It has built-in functions for solving structural mechanics problems, and its user-friendly interface allows for easy input and manipulation of data. Additionally, MATLAB's ability to handle complex mathematical equations makes it an ideal tool for analyzing and visualizing the displacement of a cantilevered beam.

## 5. What are some real-life applications of studying the displacement of cantilevered beams?

The study of displacement in cantilevered beams has many practical applications in engineering and architecture. It is used in the design and construction of structures such as bridges, buildings, and aircraft wings. Additionally, understanding the displacement of cantilevered beams can help engineers and architects make informed decisions about the materials and dimensions used in their designs, ultimately leading to safer and more efficient structures.

Replies
3
Views
919
Replies
1
Views
1K
Replies
1
Views
16K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
1K
Replies
10
Views
2K
Replies
9
Views
2K
Replies
1
Views
961
Replies
1
Views
1K