Hi I'm trying to minimize a function by solving for t at several different values for x1 and x2. I'm trying to do this in a loop but it doesnt seem like fsolve is able to solve my function. Is there something wrong with my syntax? Should the function be placed somewhere else? Here is the piece of code
for i=1:50
x0 = 1;
temp(i) = fsolve(@hw9,x0);
f = 760 - ((x1(i)*exp(-log(x1(i)+.5912*exp(-11.7755/(1.987*t))*x2(i))+x2(i)*(.5912*exp(-11.7755/(1.987*t))/...
(x1(i)+.5912*exp(-11.7755./(1.987*t))*x2(i))-(1.691*exp(-727.956/(1.987*t))/(1.691*exp(-727.956/(1.987*t))*x1(i)+x2(i))))))*10^(6.87987 -(1196.76/(219.161+t))))...
- (x2(i)*exp(-log(x2(i)+1.691*exp(-727.956/(1.987*t))*x1(i))-x1(i)*((.5912*exp(-11.7755/(1.987*t))...
/(x1(i)+.5912*exp(-11.7755/(1.987*t))*x2(i)))-(1.691*exp(-727.956/(1.987*t))/(1.691*exp(-727.956/(1.987*t))*x1(i)+x2(i))))*10^(7.33986 -(1482.29/(250.523+t)))))
end
I know it looks confusing but basically I am given vectors for x1 and x2 and I want to solve for t at different values of x1 and x2 by setting the function equal to zero

 Akzeptierte Antwort

Torsten
Torsten am 21 Nov. 2014

0 Stimmen

f = @(t) 760 - ((a*exp(-log(a+.5912*exp(-11.7755/(1.987*t))*b)+b*(.5912*exp(-11.7755/(1.987*t))/...
(a+.5912*exp(-11.7755./(1.987*t))*b)-(1.691*exp(-727.956/(1.987*t))/(1.691*exp(-727.956/(1.987*t))*a+b)))))*10^(6.87987 -(1196.76/(219.161+t))))...
- (b*exp(-log(b+1.691*exp(-727.956/(1.987*t))*a)-a*((.5912*exp(-11.7755/(1.987*t))...
/(a+.5912*exp(-11.7755/(1.987*t))*b))-(1.691*exp(-727.956/(1.987*t))/(1.691*exp(-727.956/(1.987*t))*a+b)))*10^(7.33986 -(1482.29/(250.523+t)))))
for i=1:50
a=x1(i);
b=x2(i);
x0 = 1;
temp(i)=fsolve(f,x0);
end
Best wishes
Torsten.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 20 Nov. 2014

Beantwortet:

am 21 Nov. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by