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

 Accepted Answer

Torsten
Torsten on 21 Nov 2014
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.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 20 Nov 2014

Answered:

on 21 Nov 2014

Community Treasure Hunt

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

Start Hunting!