Is it possible to import a nested package into matlab function

I have the following directory tree on my hard drive:

base_folder
base_folder \ + primary_package
base_folder \ + primary_package \ + secondary_package

Suppose in primary_package I have a function foo that calls the goo function, which is stored in secondary_package .

Value I have the following files:

base_folder \ + primary_package \ foo.m
base_folder \ + primary_package \ + secondary_package \ goo.m

Foo implementation:

  function [] = foo() primary_package.secondary_package.goo(); end 

This works, but in practice I have many calls to many functions in secondary_package , and this makes my code unreadable.

I tried the following which did not work:

 function [] = foo() import primary_package.secondary_package.*; goo(); end 

Is there a way to import a nested package to avoid many very long lines in the code?

+4
source share
1 answer
 import primary_package.secondary_package.*; goo(); 

should work fine. At least it works for me.

EDIT: make sure base_folder is in your path .

+3
source

All Articles