how to use Simpson 1/3 with different area at different time-step

3 visualizzazioni (ultimi 30 giorni)
Hi Everyone,
I tried searching the web for a solution but could not get any solutions, so i hope anyone out there could help me. First of all I am new to matlab, so please pardon my bad coding style.
What I am trying to compute is a free-fall lifeboat buoyancy force which is = density*gravity*area. However, the height of the lifeboat will be different at different step, for example:
X f(x)
0 1*3*2.3
1.4166 1*3*2.4
2.8332 1*3*2.5
4.2498 1*3*2.5
5.6664 1*3*3
7.083 1*3*3
8.5 1*3*3
At every single X there will be a different F(x) value which is the cross-section area of the lifeboat, and i need to do it for 40 segments, do you know how can i compute this? I tried as seen in the code attach, but i still having trouble at defining my function, could you help me take a look please?
Thank you
Best Regards
Noel
%INPUTS
L = 0; %lower limit
U = 8.5; % upper limit
n = 40; % number of segments
Length = 1;
Breath = 3;
density= 1.025;
g = 9.81;
func = @(Height) (Length * Breath * Height);
h = (U-L)/n;
st4 = 0;
st2 = 0;
for i = 2:h:n-1
st4 = st4 + 4*func(i);
end
for i = 3:h:n
st2 = st2 + 2*func(i);
end
I = (density*g)*(h/3*(func(1)+st4+st2+func(n)));

Risposte (0)

Categorie

Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by