Get function handle to matlab's quadprog, while shadowed by mosek
Alec Jacobson
March 05, 2012
Here's a small function I use to retrieve a function handle to MATLAB's quadprog which is shadowed when I have installed the mosek toolbox:
function [quadprog_matlab,matlab_path] = get_quadprog_matlab()
% GET_QUADPROG_MATLAB returns function handle to matlab's builtin quadprog
% (useful if, say, mosek has shadowed it)
%
% [quadprog_matlab,matlab_path] = get_quadprog_matlab();
%
% Outputs:
% quadprog_matlab function handle to matlab's quadprog
% matlab_path path to matlab's quadprog
%
% [quadprog_matlab,matlab_path] = get_quadprog_matlab();
% help(matlab_path);
% X = quadprog_matlab(H,f,A,b);
% get list of all quadprogs
paths = which('quadprog.m','-ALL');
% remember current directory
old_dir = pwd;
matlab_path = paths(~cellfun(@isempty,regexp(paths,'MATLAB')));
matlab_path = matlab_path{1};
% move to that directory
cd(regexprep(matlab_path,'quadprog.m',''));
quadprog_matlab = @quadprog;
cd(old_dir);
end