LINPROG requires the following inputs to be of data type double: 'f'.

78 views (last 30 days)
I received the following error in calling LINPROG
f=@(weit)LPSOLVE_TRADE(weit,CurrWeights,5,2);
tt=linprog(f,[],[],aeq,beq,lb,ub,weit);
f refers to LPSOLVE_TRADE which has following header
function f=LPSOLVE_TRADE(wei,CurrWeights,numtickers,numaccts)
at the end of function i have f=double(variable name)
Any advice/help guidance would be highly appreciated

Accepted Answer

Walter Roberson
Walter Roberson on 31 Jan 2016
linprog only accepts a vector for its first argument, not a function handle.
You are also passing an additional parameter beyond lb. A parameter in that position is used for x0, which is only paid attention to for Active-Set, but Active-Set needs to be specifically requested in an options argument and you have not passed an options argument.
I speculate that what you want is possibly
f = LPSOLVE_TRADE(weit,CurrWeights,5,2);
tt = linprog(f,[],[],aeq,beq,lb,ub);
That is, call LPSOLVE_TRADE with one particular weit, and use that as the vector for linprog.

More Answers (0)

Categories

Find more on Problem-Based Optimization Setup 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!