Call a function that is not on the Matlab path WITHOUT ADDING THAT PATH

后端 未结 5 1558
一生所求
一生所求 2020-12-09 10:36

I have been searching an entire afternoon and have found no solution to call in matlab a function by specifying its path and not adding its directory to the path.

Th

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 11:03

    function [varargout]=funeval(fun,varargin)
    % INPUT:
    % fun: (char) full path to function file
    curdir=cd;
    [fundir,funname]=fileparts(fun);
    cd(fundir);
    [varargout{1:nargout}] =feval(funname,varargin{:})
    cd(curdir);
    

提交回复
热议问题