I have the markowitz model shown below and I need to use the quadprog function to solve it (i.e get the values for w_i values). However I am a bit new to mat lab and not sure which definition of quadprog to use. Could someone help me with this ? thanks

2026-03-29 12:12:59.1774786379
On
Using Matlab quadprog to solve markowitz model
7k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
I know this answer is about 9 years late but according to quadprog documentation, this is what you need to do if you want to have no short selling (all weights >=0) otherwise, just remove lb and ub from the following code:
H = sigma
f = zeros(n,1)
Aeq = [ones(1,n); r']
beq = [1 r_target]
lb = zeros(n,1)
ub = ones(n,1)
w=quadprog(H , f , [] , [] , Aeq , beq , lb ,ub)
You need an
n * ncovariance matrixsigmaand a vector of expected returnsr.Your objective is to minimize
1/2 * w' * sigma * wsubject tor' * w > r_targetandones(1,n) * w = 1. Therefore, following the documentation on the Mathworks website you should call quadprog withThat is,