Filter löschen
Filter löschen

How to set up the path for a tree class download from internet?

1 Ansicht (letzte 30 Tage)
JFz
JFz am 11 Aug. 2017
Kommentiert: JFz am 14 Aug. 2017
Hi,
I downloaded a tree class from the web and put it under Matlab's main path. It works. But when I tried to make it into a package, say, +tree\@tree, It issues errors. So I typed import trees.*, and I can run some of it, but its source code does not know the path or the import trees.*.
Do I have to modify the source code to make it work under a package? I have been trying not to change the source code.
Thanks for any help.
Jennifer
  1 Kommentar
Jayaram Theegala
Jayaram Theegala am 14 Aug. 2017
What is the error that you are getting when you place the "tree" class inside a package? Also, when you are importing the package, you mentioned you can run some of it. What functions are you still not able to run and where is that function file located?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Guillaume
Guillaume am 14 Aug. 2017
Bearbeitet: Guillaume am 14 Aug. 2017
Packages in matlab do not work like namespaces in any other language I know. In particular, functions and classes within a package are not automatically visible to other functions and classes in the same packages. They still have to be referred to by their full package name (or you have to import the package in each function that need other functions/classes).
It's a real pain, particularly if later on, you change the name of the package.
In brief, you can't just put a bunch of files under a +directory and expect it to work.
Personally, I've given up on packages, they've actually caused me more pain than they've solved.
  1 Kommentar
JFz
JFz am 14 Aug. 2017
Thanks for sharing. It is indeed a pain to me, since I tried hard not to change anything in the class. for now, I just put the tree class under the default location, works for now but not elegant.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by