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 this?
If you use the import command in a MATLAB® function, add the corresponding . NET assembly before calling the function. For example, the following function getPrinterInfo calls methods in the System.
Packages are special folders that can contain class folders, function, and class definition files, and other packages. The names of classes and functions are scoped to the package folder. A package is a namespace within which names must be unique. Function and class names must be unique only within the package.
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.
You have to set the path. See here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With