Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this matlab problem. I have attached my current code. The deflection y of a sailboat mast subjected to a wind force

I need help with this matlab problem. I have attached my current code.
The deflection y of a sailboat mast subjected to a wind force can be modeled with the following differential equation:
d2ydz2=f(z)2EI(L-z)2
where z is the position along the mast starting from 0 at the base. The function f(z) is the force of the wind transferred to the mast by the sail and can be modeled as
f(z)=200z5+ze-2z30
parameter L is the length of the mast.
Write a MATLAB function P2_odesolve that will solve for deflection y(z) and the slope dydz given that the deflection and the slope are both equal to 0 at the base of the mast with the following outputs (in given order):
Solutions using Euler's method as a 2-column matrix (store solution for deflection y(z) in the first column and the solution for slope dydz in the second column)
Solutions using Heun's method (without corrector iteration) as a 2-column matrix (store solution for deflection y(z) in the first column and the solution for slope dydz in the second column)
Solutions using Midpoint method as a 2-column matrix (store solution for deflection y(z) in the first column and the solution for slope dydz in the second column)
with the following input
vector defining the span of the mast with intial and final position values (12 row vector)
initial value vector for the deflection and the slope (12 row vector)
solver step size h(scalar) Function (
1 function [yE,yH,yM]=P2 odesolve(zspan,y0,h)
2%type your code below, do not change the name of the function and the order of the variables%
Code to call your function (8)
My code:
function [yE, yH, yM]= P2_odesolve(zspan, y0, h)
% Constants
E =1.3e9;
I =0.05;
L = zspan(2)- zspan(1);
% Number of steps
N = round((zspan(2)- zspan(1))/ h);
% Initialize solution matrices
yE = zeros(N+1,2);
yH = zeros(N+1,2);
yM = zeros(N+1,2);
% Initial conditions
yE(1, :) = y0;
yH(1, :) = y0;
yM(1, :) = y0;
% Function for f(z)
f = @(z)((200* z)/(5+ z))* exp(-2* z /30);
% Euler's Method
for n =1:N
z = zspan(1)+(n-1)* h;
y = yE(n,1);
v = yE(n,2);
yE(n+1,1)= y + h * v;
yE(n+1,2)= v + h *(f(z)/(2* E * I *(L - z)^2));
end
% Heun's Method
for n =1:N
z = zspan(1)+(n-1)* h;
y = yH(n,1);
v = yH(n,2);
% Predictor step
y_star = y + h * v;
v_star = v + h *(f(z)/(2* E * I *(L - z)^2));
% Corrector step
yH(n+1,1)= y +(h /2)*(v + v_star);
yH(n+1,2)= v +(h /2)*((f(z)/(2* E * I *(L - z)^2))+(f(z + h)/(2* E * I *(L -(z + h))^2)));
end
% Midpoint Method
for n =1:N
z = zspan(1)+(n-1)* h;
y = yM(n,1);
v = yM(n,2);
% Midpoint step
y_mid = y +(h /2)* v;
v_mid = v +(h /2)*(f(z)/(2* E * I *(L - z)^2));
% Full step
yM(n+1,1)= y + h * v_mid;
yM(n+1,2)= v + h *(f(z + h /2)/(2* E * I *(L -(z + h /2))^2));
end
end
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Who is present when I give in to my bad habit?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

Describe the three parts of developing a new habit.

Answered: 1 week ago