How do I import/include MATLAB functions?

前端 未结 4 1023
谎友^
谎友^ 2021-02-11 16:13

I have some MATLAB functions defined in .m files and I\'d like to import them into MATLAB (as in I\'d like to be able to call them as I do a built-in function). How can I do thi

4条回答
  •  感情败类
    2021-02-11 17:03

    If the folder just contains functions then adding the folders to the path at the start of the script will suffice.

    addpath('../folder_x/');
    addpath('../folder_y/');
    

    If they are Packages, folders starting with a '+' then they also need to be imported.

    import package_x.*
    import package_y.*
    

    You need to add the package folders parent to the search path.

提交回复
热议问题