Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I urgentely need help with this matlab problem. I have attached my current code. What is wrong with it ? It says that the outuput
I urgentely need help with this matlab problem. I have attached my current code. What is wrong with it It says that the outuput variables have the wrong values.
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
Current 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 Pretest results are not submitted for grading. To run all the tests and submit the results for grading, click Submit.
Is the solution computed using Euler's method correct using values from the example? Pretest
Variable yE has an incorrect value.
Is the solution computed using Heun's method correct using values from the example? Pretest
Variable has an incorrect value.
Is the solution computed using Midpoint method correct using values from the example? Pretest
Variable has an incorrect value.
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