From: "stephen " <>
Newsgroups: comp.soft-sys.matlab
Subject: long summation function for fmincon
Date: Wed, 8 Dec 2010 00:40:20 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 10
Message-ID: <idmk5k$5vv$>
Reply-To: "stephen " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1291768820 6143 (8 Dec 2010 00:40:20 GMT)
NNTP-Posting-Date: Wed, 8 Dec 2010 00:40:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1678992
Xref: comp.soft-sys.matlab:693450

I have a very long function I want to use in fmincon.  This is my first post so I don't know the best way to state the function but I will attempt it like this:

f = sum (from 1 to n) sum (1 to n) x(i)*x(j) + sum (1 to n) x(i)
n = 120

so there are 14400 terms

Is there an easier way than hard coding all the terms so it will go into fmincon?

Also, at some point I will want to add coefficients to these terms from a 120x120 matrix.  How can I add that to the program?