Logan Mayfield
Logan Mayfield

Reputation: 148

Loading mat files within a package function

I'm working on an package for GNU Octave. One of the package functions uses a large, pre-computed table of data. That data is stored in a mat file which I load and unload when the function is called. The problem is that I'm unsure of a good, installation non-specific way of doing this. As near as I can tell I have to give the load command an absolute path to the mat file within the package install directory. I can see no way of getting that directory at run-time. Am I missing something or am I just going about this the wrong way?

Upvotes: 0

Views: 70

Answers (1)

Andy
Andy

Reputation: 8091

PKG_ADD is executed when the package is loaded so you can get the path where PKG_ADD resides in with __fqp__ = fileparts (mfilename ("fullpath"));From there you can init your data.

If you want the install dir from another package it's possible to load( pkg ("local_list")) and inspect local_packages.

I also think such specific Octave questions should go to the [email protected] mailinglist.

Do you want to distribute your new package on octave-forge?

Upvotes: 2

Related Questions