フィルターのクリア

Function 'subsindex' is not defined for values of class 'struct'.

1 回表示 (過去 30 日間)
Bestun
Bestun 2013 年 3 月 10 日
コメント済み: Eric Sirott 2016 年 5 月 25 日
Dear All This is a part of my code
if gurobi
clear prob
prob.obj=full(obj);
prob.A=equalityMatrix;
prob.rhs=full(equalityRHS);
prob.sense=['='];
prob.lb=full(lowerB);
prob.up=full(upperB);
params.Method=2;
params.Crossover=0;
params.outputflag = 0;
res = gurobi(prob, params);
if ~strcmp(res.status,'OPTIMAL')
disp(res.status);
end
solution=res.objval;
variables=res.x;
When I am running it I get this error: Function 'subsindex' is not defined for values of class 'struct'.
could you please inform me how to fix this problem
  4 件のコメント
Matt J
Matt J 2013 年 3 月 11 日
No, it can't be the whole thing. For example, the code below results in the error message
Error using subsindex
Function 'subsindex' is not defined for values of class 'struct'.
Error in test (line 10)
gurobi(prob,params);
Notice that it includes a line number and the specific statement that triggered the error.
gurobi=1;
params.Method=2;
params.Crossover=0;
params.outputflag = 0;
prob=params;
gurobi(prob,params);
Eric Sirott
Eric Sirott 2016 年 5 月 25 日
nope, I've had the same problem and I too was perplexed when there wasn't a line number.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 3 月 10 日
Your first line,
if gurobi
implies that gurobi is more likely a variable than a function. But later you have the line
res = gurobi(prob, params);
where prob and params are struct. If gurobi is a variable there, then you are trying to use the struct as indices, which MATLAB would give an error message for (the one you are seeing.)
In order for gurobi to be a function, then for it to be consistent with "if gurobi", then it would be necessary for it to be possible to invoke gurobi with no parameters (instead of with two parameters). That is possible, but if that is your intent then it would be clearer for readers if you were to write
if gurobi()
  2 件のコメント
Bestun
Bestun 2013 年 3 月 10 日
Dear Walter Thanks for you answer Gurobi is a solver could be used in Matlab. What did you say seems reasonable, but I am still getting the same problem
Walter Roberson
Walter Roberson 2013 年 3 月 11 日
At the MATLAB command line, enter the command
dbstop if error
then run your program. When it stops, show us which line it stopped on, and also please show us the result of
which -all gurobi
and
whos gurobi

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by