
Math Software Math Software  Mathematica, Matlab, Calculators, Graphing Software 
 LinkBack  Thread Tools  Display Modes 
July 20th, 2019, 03:26 AM  #1 
Member Joined: Sep 2013 Posts: 91 Thanks: 2  What's wrong with this matlab example?
Hello 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; showproblem(prob) Here is the link, I just copied the lines from the website(Define Problem Using Optimization Variables). https://www.mathworks.com/help/optim...lembased.html 
July 20th, 2019, 07:36 AM  #2 
Senior Member Joined: Sep 2015 From: USA Posts: 2,531 Thanks: 1390 
obj ends up being quartic in x(1) It looks like optimproblem() wants either linear or quadratic terms. 

Tags 
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 26th, 2016 11:52 PM 
Matlab Help  bigacougar22  Computer Science  0  July 28th, 2015 05:03 PM 
Matlab help  WWRtelescoping  Math Software  1  March 3rd, 2015 12:07 PM 
Matlab Help!  Abhimint  Math Software  0  January 26th, 2013 06:47 PM 
What am I doing wrong in this basic equation? Or am I wrong?  Regnes  Algebra  2  January 19th, 2012 09:58 PM 