help-octave
[Top][All Lists]
Advanced

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

Re: m-file knowing its own source location?


From: forkandwait
Subject: Re: m-file knowing its own source location?
Date: Sat, 20 Mar 2010 03:23:39 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

forkandwait <forkandwait <at> gmail.com> writes:

> 
> Hi all,
> 
> Is there a way for an m-file to reference its source code location in the 
> filesystem?  

Thanks to Carlo and Jaroslav, I ran `help mfilename`.  

This allowed me to put together the following, which finds its dataset next to 
itself in the file hierarchy (I don't have an octave blog to post this on, so 
forgive me):

[_female _male _total] = function getusapop()
  [loc name ext ver] = fileparts(mfilename("fullpathext"));
  dataf = fullfile(loc, "age5_year_sex_usa.txt");
  [_years _ages _female _male _total] = \
       textread (dataf, '%f %s %f %f %f', 'headerlines',3);
endfunction

Thanks again to everyone that makes this possible!



reply via email to

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