I keep getting unexpected matlab error in line 1

function [xr ea iter] falsepos(func, xl, xu, es, maxit)
%function [xr ea iter] falsepos(func, xl, xu, es, maxit)
%False position method
fid = fopen('falsepos_out.txt','w');
fpritnf(fid, 'Iter.\t xl\t\t f(xl)\t\t f(xr)\t\t xu\t\t f(xu)\t\t ea\n');
if func(xl)*func(xu)>0, error('no sign change'); end
xold = xl;
for iter=1:maxit
f1 = func(x1);
fu = func(xu);
xr = xu-((func(xu).*(xu-x1))./(func(xu)-func(x1)));
fr=func(xr);
ea = abs((xr-xold)/xr)*100; %approximate relative percent error
test = f1*fr;
if test<0, xu = xr;
elseif test>0, x1 =xr;
else ea = 0;
end
fprintf(fid, '%2d\t %8.5f\t %8.5 f\t %8.5f\t %8.5f\t %8.5 f\t %8.5f\t %8.1e\n',...
iter,x1,f1,xr,fr,xU,fu,ea);
if ea<es, break;end
xold = xr;
end

Respuestas (1)

Star Strider
Star Strider el 7 de Mzo. de 2018
You are missing an equal (=) sign.
Try this:
function [xr ea iter] = falsepos(func, xl, xu, es, maxit)

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 7 de Mzo. de 2018

Respondida:

el 7 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by