Function 'subsindex' is not defined for values of class 'struct'.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Matt J
am 11 Mär. 2013
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
am 25 Mai 2016
nope, I've had the same problem and I too was perplexed when there wasn't a line number.
Antworten (1)
Walter Roberson
am 10 Mär. 2013
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 Kommentare
Walter Roberson
am 11 Mär. 2013
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
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!