Get function handle to matlab’s quadprog, while shadowed by mosek

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
  quadprog_matlab = @quadprog;

Tags: , , , , , ,

One Response to “Get function handle to matlab’s quadprog, while shadowed by mosek”

  1. Ondra says:

    Thanks a lot, this function really helped me.
    However, I had to make a similar one for optimset, which is also shadowed.

Leave a Reply