Matlab unrecognized function or variable
Show older comments
p=1.23;
D=.005;
V=40;
mu=1.7910^-5;
e=.0015;
Re=pVD/mu;%reynolds number equation
f=@(x)(1/sqrt(x)+2log(e/(3.7D)+2.51/(Resqrt(x))));
a=.008;
b=.08;
while abs(b-a)>1e-9
c=(a+b)/2;
if f(a)*f(c)<0
b=c;
else
a=c;
end
end
fprintf('Root found: %.10f\n',c)
fprintf('Function value at root %E\n',f(c))
1 Comment
Walter Roberson
on 13 Dec 2020
Accepted Answer
More Answers (1)
Walter Roberson
on 13 Dec 2020
0 votes
MATLAB has absolutely no implied multiplication. If you want p multiplied by V multiplied by D then you need p*V*D not pVD .
... otherwise if you had an m and a u variable, how would it know whether that division by mu was division by the variable mu or division by (m * u) or division by m and then multiplication by u ?
1 Comment
Fatih Güler
on 13 Dec 2020
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!