1

I just realized that MATLAB cannot access functions inside a subfolder that resides inside a private folder.

I have a project that uses several functions from one MATLAB toolbox. In an attempt to make the entire project portable, I extracted the root folder of the toolbox and pasted it inside a private folder inside the project folder, so that my project could be executed in a computer that does not have that particular toolbox installed.

However, since the toolbox functions are stored inside many subfolders, this seems to prevent MATLAB from accessing them.

My idea is to preserve the toolbox folder hierarchy as is, instead of spilling the toolbox functions inside the private folder.

Why can MATLAB access functions that reside directly inside a private folder but can't access functions inside a subfolder that resides inside a private folder?

Is it possible to allow access to this subfolder?


For those of you unfamiliar with private folders, gnovice has a very good explanation here.


Example:

Take the following simplified version of the problem, where we have:

  • Three folders: Project, private and toolbox
  • Three functions: foo.m, privateFunction1.m and privateFunction2.m

With the following hierarchy:

private folder toolbox matlab

The problem:

foo.m can access privateFunction1.m but not privateFunction2.m.

Community
  • 1
  • 1
codeaviator
  • 2,545
  • 17
  • 42
  • 1
    I'm not quite understanding what you want to do, but aren't you looking for `addpath path/to/some/dir/with/code`? – Łukasz Rogalski Apr 19 '16 at 15:37
  • What operating system are you on? And what do you specifically mean by "private folder"? – Matthew Gunn Apr 19 '16 at 15:39
  • The purpose of using a private folder is that it allows access to its content only to the functions that reside in the parent folder, so you don't need to deal with paths. – codeaviator Apr 19 '16 at 15:43
  • I also have this problem, with subfolders and subsubfolders of the main folder... If you have any solution for those ones I'd appreciate – 16per9 Apr 19 '16 at 15:44
  • It's just not how private folders work. If you insist on maintaining the structure you need to `cd` to the subfolder or add it to MATLAB's path. I'd also highly recommend against copying functions from MATLAB's toolboxes since it violates your licensing agreement. – sco1 Apr 19 '16 at 19:58

0 Answers0