How to write a function of two variables, but only use one?

So I have got the following problem: I have a function that depends of two variables f(T,X2L) but I have to give values to X2L from 0 to 100 using X2L = [0:0.1:100] so I end up with 1000 ecuations to solve for every value of X2L. The problem is, when I create the function f(T,X2L) I dont know how to tell matlab "okay we are going from 2 variables to 1 and I want you to create 1000 ecuations". Also, once I got all the equations, which is the easiest way to solve them all? Thanks in advanced!
In case you need the funtion or didnt understand what I mean heres what I tried out:
%Constants of the function (these are just constants, believe me)
HVAP1 = 41400; HVAP2 = 38800;
TVAP1 = 99.974+273.15; TVAP2 = 78.32+273.15;
TACEO001 = 78.18+273.15; X2ACEO0005 = 0.893;
B =(HVAP2*X2ACEO0005^2*(1/TVAP2-1/TACEO001)-HVAP1*(1-X2ACEO0005)^2*(1/TVAP1-1/TACEO001))/(HVAP1*(1-X2ACEO0005)^2*(1-4*X2ACEO0005)*(1/TVAP1-1/TACEO001)-HVAP2*X2ACEO0005^2*(3-4*X2ACEO0005)*(1/TVAP2-1/TACEO001));
OMEGA = HVAP1*(1-TACEO001/TVAP1)/((1+3*B-4*B*X2ACEO0005)*X2ACEO0005^2);
R = 8.314472;
%My problem
X2L = 0:0.01:100;
Funcion =@(T,X2L) exp(OMEGA./(R.*T).*(1+3*B-4*B.*X2L).*X2L.^2+HVAP1/R.*(1/TVAP1-1./T)).*(1-X2L)+exp(OMEGA./(R.*T)*(1+B-4*b*X2L).*(1-X2L).^2+HVAP2/R.*(1/TVAP2-1./T)).*X2L-1;
%I have to solve T(X2L) for every ecuation in the linspace X2L = 0:0.01:100
%so now i should do...???
Funcion(T,X2L) %this wont work as i didnt give any value to "T"

Answers (1)

EDITED
The only way I can think of :
syms X2L T
Funcion =exp(OMEGA./(R.*T).*(1+3*B-4*B.*X2L).*X2L.^2+HVAP1/R.*(1/TVAP1-1./T)).*(1-X2L)+exp(OMEGA./(R.*T)*(1+B-4*B*X2L).*(1-X2L).^2+HVAP2/R.*(1/TVAP2-1./T)).*X2L-1;
X2L = 0:0.01:100;
eqns=subs(Funcion,X2L);
TL=zeros(1,numel(eqns));
for i=1:numel(eqns)
TL=solve(eqns(i),T);
end

2 Comments

Okay, Thanks you very much for being this quick! now with this I think I have the ecuations that I need to solve, but how can I solve them?
I now tried the following:
TFuncion = subs(Funcion,X2L);
TFuncion == 0;
TL = solve(TFuncion,T)
%but matlab sends the error "Undefined function or variable 'T'." Although we defined it before.
Also, I didnt forgot to give a value to "b", it was supposed to be B, sorry!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!