octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Package for level-set method?


From: Juan Pablo Carbajal
Subject: Re: Package for level-set method?
Date: Fri, 9 May 2014 14:02:46 +0200

On Fri, May 9, 2014 at 12:28 PM, Richard Crozier <address@hidden> wrote:
> On 09/05/2014 11:18, Daniel Kraft wrote:
>>
>> Hi!
>>
>> On 2014-05-09 11:44, Juan Pablo Carbajal wrote:
>>>
>>> On Fri, May 9, 2014 at 8:25 AM, Daniel Kraft <address@hidden>
>>> wrote:
>
>
>>
>> The "best" way to do that I found so far is to use mfilename() from a
>> function in the package directory (where also maze.png is installed).
>> This function is __levelset_getdir.
>>
>> But if you know a better way to locate and read maze.png from within the
>> demo, please let me know.  I could of course ask the user to enter the
>> path to one of their own image files, but I think this makes the demo
>> too tedious as an example.

Richard's answer is a solution, you can go system specific by doing
# Option 1
installed_pkgs_lst = pkg("list");
pkg_folder = installed_pkgs_lst (cellfun(@(x) ismember (x.name,
{"level-set"}), installed_pkgs_lst, "unif", true)){1}.dir

# Option 2
#pkg_data = pkg ("describe","level-set"){1};
#pkg_name = [pkg_data.name "-" pkg_data.version];
#pkg_folder = fullfile (pkg("prefix") , pkg_name)

imgfile = fullfile (pkg_folder,"maze.png");



Option 1 is probably the safest. You can check existence with function "exists"

>>
>> Yours,
>> Daniel
>>
>
> how about
>
> fullfile(fileparts (which('an_m_file_in_the_dir.m'), 'maze.png'))
>
> or something like this
>
> I often put a function in directories of interest like below for similar
> reasons:
>
> function path = linearmachinerootdir()
>
>     path = getmfilepath(mfilename);
>
> end
>
>
>
> where getmfilepath. is just
>
>
>
> function filepath = getmfilepath(mfile)
> % getmfilepath: gets the directory containing an mfile
> %
> % Syntax
> %
> % filepath = getmfilepath(mfile)
> %
> % Input
> %
> % mfile is a string containing the name of the mfile for which the
> % location is to be found, the .m extension is optional
> %
> % Output
> %
> % filepath is the directory path containing the specified mfile
> %
>
>     if exist(mfile, 'file') == 2
>
>        filepath = fileparts(which(mfile));
>
>     else
>         error('UTILS:nofile', 'm-file does not appear to exist')
>     end
>
> end
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]