problem-based quadprog in R2017b
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, trying to solve a 2rd order min problem in R2017b using the problem-based methods. I'm getting Undefined function 'mpower' for input arguments of type 'optm.problemdef.OptimizationVariable'. Code below. I had a similar type problem using the online help which I believe is for a more recent version of MATLAB. I’m using R2017b. I prefer the problem-based approach – just seems less date entry error prone and I’m more of an object-oriented user.
x = optimvar('x',2); %
% Using quadratic programming
objec = 2*x(1) + x(2) - (x1)^2; ! (error in this line)
prob = optimproblem('Objective',objec);
% Constraints
prob.Constraints.cons1 = 2*x(1) + 3*x(2) <= 6;
prob.Constraints.cons2 = 2*x(1) + x(2) <= 4;
prob.Constraints.cons3 = x(1) >= 0;
prob.Constraints.cons4 = x(2) >= 0;
problem = prob2struct(prob);
[x, fval] = quadprog(problem)
Undefined function 'mpower' for input arguments of type 'optim.problemdef.OptimizationVariable'.
I’m following an example openExample('optim/QuadraticProblemFromProb2structExample')
But this isn’t in my version; I run the command with the following error
>> openExample('optim/QuadraticProblemFromProb2structExample')
Error using findExample (line 35)
Example "QuadraticProblemFromProb2structExample" not found in "C:\Program Files\MATLAB\R2017b\examples\optim\examples.xml".
Error in setupExample (line 5)
metadata = findExample(arg);
Error in openExample (line 10)
[metadata,workDir] = setupExample(varargin{:});
Questions are (1) how to fix the syntax, (2) is the help for R2017b accessible? Currently I hit Help and get R2018x, so it seems (I don’t know what x version is current), and (3) is it “better” to upgrade to the current MATLAB to work around the version-help mismatch?
Regards,
Jon
0 commentaires
Réponses (1)
Walter Roberson
le 6 Mar 2019
x1 is not defined . I suspect you have x(1)^2
R2018a and r2017b only support linear problems . Quadratic problems were not supported until r2018b .
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Least Squares dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!