Thread Subject: anyone know how to have a subroutine return its location?

Subject: anyone know how to have a subroutine return its location?

From: jay vaughan

Date: 19 Apr, 2008 20:46:01

Message: 1 of 4


Hi,

I would like to have a function indicate the path where it
is located upon being called, but I haven't been able to
figure out how to have the function generate that info. It
seems like it should be simple.

For now, I am just entering the path manually into the
function, but it would be nicer if the function would be
able to generate the path automatically so when I give it to
other people (as part of a package) they don't have to
fiddle with it.


Thanks,
J

Subject: anyone know how to have a subroutine return its location?

From: Abel Brown

Date: 19 Apr, 2008 20:53:01

Message: 2 of 4

"jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message
<fudlm9$quu$1@fred.mathworks.com>...
>
> Hi,
>
> I would like to have a function indicate the path where it
> is located upon being called, but I haven't been able to
> figure out how to have the function generate that info. It
> seems like it should be simple.
>
> For now, I am just entering the path manually into the
> function, but it would be nicer if the function would be
> able to generate the path automatically so when I give it to
> other people (as part of a package) they don't have to
> fiddle with it.
>
>
> Thanks,
> J


um ... 'help pwd'

Subject: anyone know how to have a subroutine return its location?

From: Bruno Luong

Date: 19 Apr, 2008 20:54:01

Message: 3 of 4

"jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message
<fudlm9$quu$1@fred.mathworks.com>...
>
> Hi,
>
> I would like to have a function indicate the path where it
> is located upon being called, but I haven't been able to
> figure out how to have the function generate that info. It
> seems like it should be simple.
>
> For now, I am just entering the path manually into the
> function, but it would be nicer if the function would be
> able to generate the path automatically so when I give it to
> other people (as part of a package) they don't have to
> fiddle with it.
>
>

mfilename
fileparts

Bruno

Subject: anyone know how to have a subroutine return its location?

From: jay vaughan

Date: 19 Apr, 2008 21:35:03

Message: 4 of 4


Thanks Bruno, that did the trick perfectly!

J

(Abel, pwd only tells you the current directory in the
workspace, not where the subroutine is called from.)

"Bruno Luong" <b.luong@fogale.fr> wrote in message
<fudm59$77d$1@fred.mathworks.com>...
> "jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message
> <fudlm9$quu$1@fred.mathworks.com>...
> >
> > Hi,
> >
> > I would like to have a function indicate the path where it
> > is located upon being called, but I haven't been able to
> > figure out how to have the function generate that info. It
> > seems like it should be simple.
> >
> > For now, I am just entering the path manually into the
> > function, but it would be nicer if the function would be
> > able to generate the path automatically so when I give it to
> > other people (as part of a package) they don't have to
> > fiddle with it.
> >
> >
>
> mfilename
> fileparts
>
> Bruno

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com