Am I using the fminsearch correctly?

조회 수: 2 (최근 30일)
A K
A K 2016년 10월 27일
댓글: Walter Roberson 2016년 10월 27일
I don't seem to be converging to the correct value whilst using fminsearch, does anyone know if this layout is correct?
function reboiler_temp=bubble_point(x,A,B,C,P,bubble_components,T);
% calculate the temperature for the individual components
%input_data=get_input_data();
temp=0;
bubble_temp=zeros(bubble_components);
for i=1:bubble_components
bubble_temp(i)=10^(A(i)-B(i)/(T+C(i)))*x(i);
temp=temp+bubble_temp(i);
end
temp
reboiler_temp=abs(temp-P)
return;
In the script i have this:
T(1)=input_data.simulation_data.reboiler_temp;
reboiler_temp= fminsearch(@bubble_point,T(1),[],x,A,B,C,P,bubble_components)

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 27일
In your line
reboiler_temp=sum(temp)-P;
what is temp ?
Why do you loop through calculating bubble_temp but then overwrite it with the result of your fminsearch?
Why do you create a function handle with parameter bubbletemp and then ignore the parameter? Why is that function handle relying upon the value of i that just happens to be "left over" from the for i loop?
  댓글 수: 2
A K
A K 2016년 10월 27일
sorry, I have changed it now. The equation is implicit in T but each input argument apart from T has two values, so I use the for loop to find the sum which gives me the equation i want to find the minimum of.
I then use fminsearch on the result to find T - but i'm not sure how to go about it
Walter Roberson
Walter Roberson 2016년 10월 27일
reboiler_temp= fminsearch(@(t) bubble_point(x, A, B, C, P, bubble_components, t), T(1))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by