overrideBuiltInFunction - aleslab/Psychtoolbox-3-aleslab-fork GitHub Wiki

Method to override a MATLAB built-in function with a user-supplied function
with the same name. The way this works is that it replaces the built-in function
with a function handle parameter whose name matches that of the overriden
function.

Usage:
functionName = overrideBuiltInFunction('functionName', overridingFunctionPath);

  where the overridingFunctionPath string can be the full path to the overriding  
  function or a uniquely-identifying subset of the full path.  

  This call must be done in the script where you will use the override.   
  To use across several scripts, make it a global function handle:  

  global functionName  
  functionName = overrideBuiltInFunction('functionName', overridingFunctionPath);  

Example Usage:
Override Matlab's built-in function lab2xyz with the one supplied by ISETBIO
located in '/Users/Shared/Matlab/Toolboxes/ISETBIO/isettools/color/transforms'

  lab2xyz = overrideBuiltInFunction('lab2xyz', 'isetbio');  

Test that it works:
clear all
functions(@lab2xyz)
lab2xyz = overrideBuiltInFunction('lab2xyz', 'isetbio');
functions(lab2xyz)

Undoing the override:
To 'unoverride', simply clear the function handle. This should bring back
the built-in function, e.g.:

  clear lab2xyz  

10/9/2014 NPC Wrote it.

Path   Retrieve current version from GitHub | View changelog
Psychtoolbox/PsychOneliners/overrideBuiltInFunction.m
⚠️ **GitHub.com Fallback** ⚠️