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