Azzera filtri
Azzera filtri

Solving an Equation without solve command

2 visualizzazioni (ultimi 30 giorni)
Georgios Vamvakopoulos
Georgios Vamvakopoulos il 17 Ago 2016
Risposto: Luke Halberstadt il 17 Ago 2016
Hello Everyone,
I'm trying to solve the following equation for h
My problem is that the equation can't have an exact solution. However, there is a tolerance of 0.05. Therefore, I can't use the solve( command. I tried to obtain a solution but I couldn't. Do you guys have a suggestion?. Thank you in advance. This is my code;
load cal.mat
% Parameters
g = 9.81; % Gravity acceletration
% Inputs
Q = 40; % (m^3/sec)
So = 0.02 % slope of the channel
W = 4 % width of the channel
H = 3 % Depth of water
hin = H % depth of the water
hv = hin;% height of the canopy
% Obtain initial data
A = W*H % Cross-sectional Area of the Channel
P = W + hin + hin
R = A/P
% Setting Tolerance
Tol = 0.05 %meter
dif = 1
ht1 = hin + 0.01
ht = hin
for i=1:100
U = Q/A;
while dif > Tol
% for trees
ht = (((U)^2)*((g*((cal(i,2))^2)/(ht^(1/3))+0.5*((cal(i,1))*(cal(i,4))*ht*(cal(i,3))))))/(g*(1-0.25*(cal(i,4)*pi*((cal(i,3))^2))))
dif = ht1-ht
ht = ht + 0.01
end
end

Risposte (1)

Luke Halberstadt
Luke Halberstadt il 17 Ago 2016
Why are you not permitted to find an exact solution? The equation you gave can be solved directly for h since if you look carefully, it is in the form h = a/h^(1/3) + b*h, which can be converted to h = (a/(1-b))^(3/4).

Categorie

Scopri di più su Thermal Analysis 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