erogol
erogol

Reputation: 13614

How can I group Matlab scripts on folders as executing from the main script at parent folder?

I have a dozen of scripts already and I want to group them under folders to deal with them with more ease. How could I do it? Does Matlab includes Packet hierarchy? If it does, I cannot find how to use :(.

Upvotes: 3

Views: 153

Answers (1)

Rody Oldenhuis
Rody Oldenhuis

Reputation: 38032

Yes, Matlab uses package directories for that.

Group the files in a directory starting with a '+':

+somePackage/func1.m
+somePackage/func2.m

then, in your main script,

import someDir.*

A = func1(arg1, arg2, ...);
B = func2(arg1, arg2, ...);

or

A = somePackage.func1(arg1, arg2, ...);
B = somePackage.func2(arg1, arg2, ...);

This is basically Matlab's implementation of the concept of namespaces.

Upvotes: 5

Related Questions