Quantcast
Channel: MATLAB Central Newsreader - tag:"optimization"
Viewing all articles
Browse latest Browse all 130

Mean-Variance Optimization, Optimal Weights Problem

$
0
0
Hi All,

I have what is probably a very simple problem that has me scratching my head. I am a beginner MatLab user and am therefore following the Mathworks documentation very closely. However, for the following, I cannot figure out what is wrong.

I have the following function:

function [Weights] = myfun(w,sigmahat)
Weights = @(w)w'*sigmahat*w;

And then the following code:

muhat = [0.0427 0.0015 0.0285];
sigmahat = [0.0100 0.0018 0.0011; 0.0018 0.0109 0.0026; 0.0011 0.0026 0.0199];
TargetReturn=0.0285;
X0=zeros(3,1);
Aeq = [muhat;ones(1,3)];
Beq = [TargetReturn;1];
A = [];
B = [];
LB = zeros(3,1);
UB = ones(3,1);

[OptimalWeights, OptimalVariance] = fmincon(Weights,X0,A,B,Aeq,Beq,LB,UB);

I get the following errors when I run this:

Error using Weights (line 3)
Not enough input arguments.

Error in Practice (line 12)
[OptimalWeights, OptimalVariance] = fmincon(Weights,X0,A,B,Aeq,Beq,LB,UB);

I copied this almost verbatim from the following as it is the exact same problem:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/271112

I need any help that can be offered. When I google the errors, I do not receive helpful information.
Thank you so much for your time.

Viewing all articles
Browse latest Browse all 130

Trending Articles