fminunc not working when passing extra paramaters

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

The calling syntax looks fine. Whatever the problem is, it is coming from elsewhere in the code.
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.
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.

Sign in to comment.

Answers (0)

Asked:

on 28 May 2019

Commented:

on 28 May 2019

Community Treasure Hunt

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

Start Hunting!