MATLAB Answers

Best guess/optimization solution needed

조회 수: 2(최근 30일)
Oliver Higbee
Oliver Higbee 2021년 4월 30일
댓글: Bjorn Gustavsson 2021년 5월 13일
Hi there,
I have a series of equations which derive the maximium current of a wire, many of these terms have temperature dependance.
I'd like to reverse engineer this and find the temperature that results in a specific current. Given there are many temperature dependant terms (not all of which are linear), rearranging to make temperature the subject is not possible. (or extremely difficult).
As a human, I could use best guesses and keep changing the temperature until I arrive at the current I was looking for. What method in Matlab can I use to acheieve this? (I think it's some kind of optimisation problem but not sure on the specifics of which method to use)
Kind regards,
Oliver
  댓글 수: 1
DGM
DGM 2021년 4월 30일
Can you not use fzero() for this?

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

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2021년 4월 30일
From the information you've given this sounds like a "reasonably" straightforward optimization-problem. You could try something like this:
function I = your_current_function(T,other_parameters)
I = f1(T,other_paramters(1:7)) + f2(T,other_parameters(3:5:13)); % you know what to do
end
Then you can try to find the exact current with fzero:
I_target = 123;
T_0 = fzero(@(T) your_current_function(T,other_parameters)-I_target,280);
Or find the temperature that gets you closest to you target current using fminsearch:
I_target = 123;
T0 = 280;
T_best = fminsearch(@(T) (I_target - your_current_function(T,other_parameters)).^2,T0);
HTH
  댓글 수: 2
Bjorn Gustavsson
Bjorn Gustavsson 2021년 5월 13일
No, fminsearch handles multidimensional searches. It only operates on one input-argument, but that input argument can be an array with all your parameters. For example if you have a temperature and a length as optimization-paramters your model-function might be modified to simething like this:
function I = your_current_function(TnL,other_parameters)
T = TnL(1); % For readability I find it neat to explicitly
L = TnL(2); % extract the different parameters from the parameter-array
I = L*f1(T,other_paramters(1:7)) + (L-1)*L*f2(T,other_parameters(3:5:13)); % you know what to do
end
Then you have to make a 2-element start-guess and call fminsearch with that and hopefully it will converge to a good solution:
I_target = 123;
T0 = 280;
L0 = 1;
T0nL0 = [T0,L0];
% Then for a 2-D function to be equal to one single value will not
% necessarily give you a single unique point for the problem you described
% - for the case where you have a nice smoothly varying output-variable you
% most likely get at least one contour with that satisfy the
% "target-current". But if you have multiple outputs (current and power for
% example) you might get a unique solution. Or if your target-function surface has
% a minima it might be found:
T_best = fminsearch(@(TL) your_current_function(TL,other_parameters)).^2,T0nL0);

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

추가 답변(0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by