My Math Forum  

Go Back   My Math Forum > Math Forums > Math Software

Math Software Math Software - Mathematica, Matlab, Calculators, Graphing Software

LinkBack Thread Tools Display Modes
July 20th, 2019, 04:26 AM   #1
Joined: Sep 2013

Posts: 93
Thanks: 2

What's wrong with this matlab example?


I'm trying to create an optimization problem in matlab, but I get this error:

Error using optim.internal.problemdef.Power
Result of operation must be linear or quadratic.
Error in .^
Error in ^
Error in rosenbrock_opt (line 2)
obj = 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;

The matlab code:

x = optimvar('x',1,2);
obj = 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;
prob = optimproblem('Objective',obj);
nlcons = x(1)^2 + x(2)^2 <= 1;
prob.Constraints.circlecons = nlcons;

Here is the link, I just copied the lines from the website(Define Problem Using Optimization Variables).
ricsi046 is offline  
July 20th, 2019, 08:36 AM   #2
Senior Member
romsek's Avatar
Joined: Sep 2015
From: USA

Posts: 2,637
Thanks: 1472

obj ends up being quartic in x(1)

It looks like optimproblem() wants either linear or quadratic terms.
romsek is offline  

  My Math Forum > Math Forums > Math Software

matlab, optimization, wrong

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which is use of matlab MMath Math Software 6 May 27th, 2016 12:52 AM
Matlab Help bigacougar22 Computer Science 0 July 28th, 2015 06:03 PM
Matlab help WWRtelescoping Math Software 1 March 3rd, 2015 01:07 PM
Matlab Help! Abhimint Math Software 0 January 26th, 2013 07:47 PM
What am I doing wrong in this basic equation? Or am I wrong? Regnes Algebra 2 January 19th, 2012 10:58 PM

Copyright © 2019 My Math Forum. All rights reserved.