fminunc not working when passing extra paramaters
Show older comments
I have a function that is called with several variables: efficiency_V2(x,C,D,E)
x is the variable which I would like to optimize for whilst holding C,D and E constant. x is a column vector of different variables. There are many more functions that call these variables within this one function and it is a deep network of code. Currently I am calling fminunc as such:
fminunc(@(x)efficiency_multijunction_V2(x,1,'gt','a'),[2e-4;110e-4])
This is not working however. Do I need to restructure the variables?
3 Comments
Matt J
on 28 May 2019
The calling syntax looks fine. Whatever the problem is, it is coming from elsewhere in the code.
John D'Errico
on 28 May 2019
Edited: John D'Errico
on 28 May 2019
Yes. That is what you would do. Although I do see a disconnect, in that you say in one place the call is to
efficiency_V2(x,C,D,E)
yet in another, we see a different function name.
efficiency_multijunction_V2(x,1,'gt','a')
This could be the entire problem, or it might just indicate your typing was lazy as hell when you posed the question.
Anyway, that it is not working is not sufficient information. The problem lies in your deep network of code. Time to use the debugger, I think.
Steven Lord
on 28 May 2019
Can you clarify what "not working" means?
Does MATLAB throw an error? If so show us the full text of the error message, all the red text.
Does MATLAB issue a warning? If so show us the full text of the error message, all the orange text.
Does it give you a different answer than you expected? If so show us the full code for your problem as well as the answer you receive and the answer you expected.
Does it do something else? If so please explain in more detail.
Answers (0)
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!