フィルターのクリア

error with my symbolic objects and fprintf

3 ビュー (過去 30 日間)
doliph
doliph 2013 年 9 月 10 日
コメント済み: Qutyba Shteyat 2021 年 5 月 31 日
I am quite inexperienced with matlab, I am getting this error when I run:
Error using fprintf
Function is not defined for 'sym' inputs.
Error in colebrook (line 22)
fprintf('%3i %12.8s %12.8s %12.8s\n',count, x, dx, f)
function colebrook (f,Re,e)
syms e Re x;
df = diff(1/sqrt(x)+2*log(e/3.7+2.51/(Re*sqrt(x))),x);
Tol = .001;
x=.02;
count = 0;
dx = 1;
fprintf('step x dx f(x)\n')
fprintf('---- ----------- --------- ----------\n')
fprintf('%3i %12.8f %12.8f %12.8f\n',count, x, dx, f)
xVec=x;fVec=f;%eVec=e;ReVec=Re;
while (dx > Tol || abs(f)>Tol)
count = count + 1;
xnew = x - (f/df);
dx=abs(x-xnew);
x = xnew;
f = (1/sqrt(x)+2*log(e/3.7+2.51/(Re*sqrt(x))));
fprintf('here');
e = char (e);
Re = char (Re);
x = char (x);
fprintf('%3i %12.8s %12.8s %12.8s\n',count, x, dx, f)
end

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 9 月 10 日
xnew = x - double(f(x)/df(x));
  1 件のコメント
Qutyba Shteyat
Qutyba Shteyat 2021 年 5 月 31 日
Thankssssssssssss

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by