I have an .m file in matlab named PowerMinimiser
and two functions in it
function PowerMinimiser
PowerOut = fmin(minFunction,0,100);
display(PowerOut)
end
and
function PowerOut = minFunction(varargin)
RunMode = 2;
ThresholdValue = 10;
if nargin > 0
ThresholdValue = varargin{1};
end
%Receive PowerOut value from .main file and pass in ThresholdValue and
%RunMode values:
[PowerOut] = main(ThresholdValue,RunMode);
end
Now what I would like to do is use the matlab fmin
function so that I can find a value for the variable ThresholdValue
which will give the lowest value possible for the variable PowerOut
. The value for ThresholdValue
is a number between 1 and 100, and is passed into a function in the main.m
where a number of calculations are done and then a value for PowerOut
is outputted.
Using the minFunction
function I am able to receive and pass the variable fine, using the line
[PowerOut] = main(ThresholdValue,RunMode);
but I am not sure how to use the fmin
function to get the value of ThresholdValue
that gives the lowest value for PowerOut
. I would like the ThresholdValue
value to be shown once the fmin
has done the necessary calculations. How can I do this? Any help would be greatly appreciated.
Thanks