Distributed load along a beam, Finite difference method and ode 45 errors

13 ビュー (過去 30 日間)
Megan Hewison
Megan Hewison 2021 年 12 月 8 日
I have been working on this for a while but still not managed to get any graphs that make any sense, please see problem statement and code and graphs i have managed so far below
close all
clear all
clc
%variables
E=29*10^6; % elastic modulus (psi)
I=723; % moment of inertia (in^4)
q=500; %disrubuted load (lb/in)
L=36; %length
%equation
x=linspace(0,L);
y=((-q.*x.^2)/(24*E*I).*(6.*(L.^2)-4.*L.*x+x.^2));
%part a
%finite difference method
dx=6;
xx=0:dx:L;
yo=0;
yn=0;
ya=((dx.^2*q/(E*I))*((-L.^2/2)+L.*0-0.^2/2))/2;
A = [1 0 0 0 0;
-2 1 0 0 0;
1 -2 1 0 0;
0 1 -2 1 0;
0 0 1 -2 1];
z2=(dx.^2*q/(E*I))*((-L.^2/2)+L);
b = [(z2*xx(1)-xx(1).^2/2)+2*ya;
(z2*xx(2)-xx(2).^2/2)-ya;
(z2*xx(3)-xx(3).^2/2);
(z2*xx(4)-xx(4).^2/2);
(z2*xx(5)-xx(5).^2/2)];
yi=A\b;
yb=[yo yi(1:4)' yn yi(5)];
plot(x,y, 'r-',xx,yb, 'b')
hold
on
grid on
title('Graph of beam deflection')
xlabel(
'distance along beam(in)')
ylabel(
'deflection of beam (in)')
%part c
tspan=[0,36];
za=fzero(@res_project2,6);
y0=[0 za];
[x,yy]=ode45(@sys_project2,tspan,y0);
plot(x,yy(:,1),'k',x(1),yy(1,1),'og',x(end),y(end,1),'og')
legend(
'analytical','finite differance','shooting method','endpoints')
hold
off
%part d
xd=0:dx:L;
y=((((-q*x.^2)/24))/E*I);
ea=abs(y-ya);
figure(2)
plot(x,ea)
hold on
grid on
xlabel('distance along beam')
ylabel(
'abs error')
x=0:L:57;
[x,yy]=ode45(@sys_project2,tspan,y0);
ec=abs(y-yy(:,1));
plot(x,ec(:,1))
legend('fdm error','shooting method error')
% part e
% part f
% part g

回答 (0 件)

カテゴリ

Help Center および File ExchangeAssembly についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by