Answered step by step
Verified Expert Solution
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 of a sailboat mast subjected to a wind force can be modeled with the following differential equation:
where is the position along the mast starting from at the base. The function is the force of the wind transferred to the mast by the sail and can be modeled as
parameter is the length of the mast.
Write a MATLAB function Podesolve that will solve for deflection and the slope given that the deflection and the slope are both equal to at the base of the mast with the following outputs in given order:
Solutions using Euler's method as a column matrix store solution for deflection in the first column and the solution for slope in the second column
Solutions using Heun's method without corrector iteration as a column matrix store solution for deflection in the first column and the solution for slope in the second column
Solutions using Midpoint method as a column matrix store solution for deflection in the first column and the solution for slope in the second column
with the following input
vector defining the span of the mast with intial and final position values row vector
initial value vector for the deflection and the slope row vector
solver step size scalar Function
function odesolvezspan
type your code below, do not change the name of the function and the order of the variables
Code to call your function
My code:
function yE yH yM Podesolvezspan y h
Constants
E e;
I ;
L zspan zspan;
Number of steps
N roundzspan zspan h;
Initialize solution matrices
yE zerosN;
yH zerosN;
yM zerosN;
Initial conditions
yE :) y;
yH :) y;
yM :) y;
Function for fz
f @z z z exp z ;
Euler's Method
for n :N
z zspann h;
y yEn;
v yEn;
yEn y h v;
yEn v h fz E I L z;
end
Heun's Method
for n :N
z zspann h;
y yHn;
v yHn;
Predictor step
ystar y h v;
vstar v h fz E I L z;
Corrector step
yHn y h v vstar;
yHn v h fz E I L zfz h E I L z h;
end
Midpoint Method
for n :N
z zspann h;
y yMn;
v yMn;
Midpoint step
ymid y h v;
vmid v h fz E I L z;
Full step
yMn y h vmid;
yMn v h fz h E I L z h ;
end
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started