i need some help for fsolve function with input data

v,t are input variable and x must be calculate.when run my code repeat input data request without answer!!
function f=vogel(v,t,x)
t(1)=input('temp1:');
t(2)=input('temp2:');
t(3)=input('temp3:');
v(1)=input('vis1:');
v(2)=input('vis2:');
v(3)=input('vis3:');
x(1)=input('estim a:');
x(2)=input('estim b:');
x(3)=input('estim c:');
f(1)=log(v(1))-log(x(1))-(x(2)/((t(1)+273.15)-x(3)));
f(2)=log(v(2))-log(x(1))-(x(2)/((t(2)+273.15)-x(3)));
f(3)=log(v(3))-log(x(1))-(x(2)/((t(3)+273.15)-x(3)));
[x,fval] = fsolve(@(x) vogel(v,t,x), x);
end

 Respuesta aceptada

You are writing everything in one file, which is not correct. Save the following file as vogel.m
function f=vogel(v,t,x)
f(1)=log(v(1))-log(x(1))-(x(2)/((t(1)+273.15)-x(3)));
f(2)=log(v(2))-log(x(1))-(x(2)/((t(2)+273.15)-x(3)));
f(3)=log(v(3))-log(x(1))-(x(2)/((t(3)+273.15)-x(3)));
end
Then in another script write
t(1)=input('temp1:');
t(2)=input('temp2:');
t(3)=input('temp3:');
v(1)=input('vis1:');
v(2)=input('vis2:');
v(3)=input('vis3:');
x(1)=input('estim a:');
x(2)=input('estim b:');
x(3)=input('estim c:');
[x,fval] = fsolve(@(x) vogel(v,t,x), x);

Más respuestas (0)

Categorías

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

Preguntada:

el 30 de Abr. de 2016

Comentada:

el 30 de Abr. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by