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

 採用された回答

Torsten
Torsten 2014 年 11 月 21 日

0 投票

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.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

質問済み:

2014 年 11 月 20 日

回答済み:

2014 年 11 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by