필터 지우기
필터 지우기

Solving an Equation without solve command

조회 수: 2 (최근 30일)
Georgios Vamvakopoulos
Georgios Vamvakopoulos 2016년 8월 17일
답변: Luke Halberstadt 2016년 8월 17일
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

답변 (1개)

Luke Halberstadt
Luke Halberstadt 2016년 8월 17일
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).

카테고리

Help CenterFile Exchange에서 Thermal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by