function err=optcontr4(n,m)
A = (n+1)*(n+1)*(sparse(2:n,1:n-1,-1,n,n) + sparse(1:n,1:n,2,n,n) + sparse(1:n-1,2:n,-1,n,n));
obs = sparse(m,n);
for i=1:m
  index=int8((i-0.5)/m*(n+1));
  obs(i,index)=1.;
end
mat1 = horzcat(A,-speye(n),sparse(n,m));
mat2 = horzcat(sparse(n,n),A',-obs');
mat3 = horzcat(obs,sparse(m,n),sparse(m,m));
mat  = vertcat(mat1,mat2,mat3);
xobs=A\ones(n,1);
b = 0.9*ones(n,1);
rhs  = vertcat(b,sparse(n,1),obs*xobs);
sol=mat\rhs;
x=sol(1:n);
q=sol(n+1:2*n);
mu=sol(2*n+1:end);
hold on
plot(x,'o');
plot(xobs,'+');
plot(q,'x');
err=max(abs(x-xobs));
end

