필터 지우기
필터 지우기

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));

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by