error with my symbolic objects and fprintf

1 visualización (últimos 30 días)
doliph
doliph el 10 de Sept. de 2013
Comentada: Qutyba Shteyat el 31 de Mayo de 2021
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

Respuestas (1)

Walter Roberson
Walter Roberson el 10 de Sept. de 2013
xnew = x - double(f(x)/df(x));

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by