How to use the shooting method in matlab The governing diffe

How to use the shooting method in matlab
The governing differential equation for the deflection of a cantilever beam subjected to a point load at its free end (Fig. 1) is given by: EI_zz d^2 y/dx^2 = -Px where E is classic modulus, is beam moment of inertia, y is beam deflection, P is the point load, and x is the distance along the beam measured from the free end. The boundary conditions arc the deflection y (L) is zero and the slope (dy/dr) at x=L is zero, where L is beam length. Solve for the deflection of the beam using the shooting method. Use 1=2 m, /77= 0.0005 m4, P= 10 kN, and E= 200,000 MPa. Provide a plot comparing your results against the analytical solution given by: y(x) = - P/6 EI_zz (L - x)^2 (2L + x)

Solution

function [x y] = shooting_method(fun,h,zero,a,b,con,type,init) tic; if (h <= 0) || (zero <= 0) || (a>=b) || (length(con) ~= 2) || (length(type) ~= 2) error(\'Check validity of input parameters - non-negative of accuracy and length of arrays\'); end if nargin == 8 shoot1 = init(1); shoot2 = init(2); else shoot1 = -10; shoot2 = 10; end if (type(1)==\'f\') a1 = [con(1) shoot1]; a2 = [con(1) shoot2]; else a1 = [shoot1 con(1)]; a2 = [shoot2 con(1)]; end [~, F1] = RungeKutta(a,b,h,a1,fun); [~, F2] = RungeKutta(a,b,h,a2,fun); if (type(2)==\'f\') F1 = F1(1,end) - con(2); F2 = F2(1,end) - con(2); r = 1; else F1 = F1(2,end) - con(2); F2 = F2(2,end) - con(2); r = 2; end if (F1*F2 > 0) error(\'The root of F function does not exist, for selected initialization parameters. Please, change the init array.\') end F3 = F1; while (abs(F3) > zero) shoot3 = (shoot1 + shoot2)/2; if (type(1)==\'f\') a3 = [con(1) shoot3]; else a3 = [shoot3 con(1)]; end [x, F3] = RungeKutta(a,b,h,a3,fun); y = F3; F3 = F3(r,end) - con(2); if (F1*F3 < 0) shoot2 = shoot3; F2 = F3; elseif (F1*F2 < 0) shoot1 = shoot3; F1 = F3; else error(\'Selhani metody puleni intervalu, zmente init\'); end end h = plot(x,y(1,:),\'k-\'); set(h,\'linewidth\',2); hold on; h = plot(x,y(2,:),\'r-\'); set(h,\'linewidth\',2); xlabel(\'{\\it x}\',\'FontSize\',12); ylabel(\'y({\\it x }), y^{(1)}({\\it x })\',\'FontSize\',12); title(\'Solution of 1D Boundary Value Problem by Shooting Method\',\'FontSize\',12); set(gca,\'FontSize\',12); legend(\'Function\',\'{1^{st}} Derivative\',\'Location\',\'Best\'); hold off; toc;
How to use the shooting method in matlab The governing differential equation for the deflection of a cantilever beam subjected to a point load at its free end (

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site