Best guess/optimization solution needed

4 views (last 30 days)
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

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 30 Apr 2021
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 Comments
Oliver Higbee
Oliver Higbee on 13 May 2021
Thanks Bjorn, that's exactly what I was looking for!
If I wanted to expand the problem further and optimize around multiple parameters, how would I do this? fzero and fminsearch can only handle one parameter at a time by the looks of it.
Bjorn Gustavsson
Bjorn Gustavsson on 13 May 2021
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);

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!