migrating from Matlab to Octave 20080513 - cd
Dan Kien
Dan.Kien at earthlink.net
Tue May 13 14:59:44 CDT 2008
As a new Octave user, I found the following issues (somewhat trivial) in
migrating my Matlab code to Octave. Thanks - DjK.
Issue
1.) A return value for 'cd' is not allowed in Octave as it is for Matlab,
and,
2.) The required function ('pwd') is not cross-referenced in the help
documentation for 'cd'.
Explanation
In MATLAB I used the 'cd' function to return the pwd info. Octave does
not allow this.
Proposed Interim Solution
Add 'pwd' to list of cross-referenced keywords under "See also:" in all
help documentation for the functions: 'cd' 'mkdir' 'rmdir' 'dir' 'readdir'
'isdir' 'what' 'which' 'exist' and 'ls'. Additionally, it'd be useful if
these functions all had the same cross-reference list in their respective
help file.
Proposed Long-Term Solution
Change 'cd' command to a function and allow it to return the current
directory info for compatibility with Matlab.
For instance, before explicitly changing the working directory, I'd record
the current directory info so it could be restored when
I finished. Using the same command for all 3 lines makes the code a little
easier to learn (less to look up).
CurrentDirectory = cd;
cd(PROGRAM_PATH);
.
cd(CurrentDirectory);
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/hel
pdesk/help/techdoc/ref/f16-6011.html
MATLAB Function Reference
cd - Change working directory
Syntax
cd
w = cd
cd('directory')
cd('..')
cd directory
Description
cd displays the current working directory.
w = cd assigns the current working directory to w.
cd('directory') sets the current working directory to directory. Use the
full pathname for directory. On UNIXR platforms, the character ~ is
interpreted as the user's root directory.
cd('..') changes the current working directory to the directory above it.
cd directory or cd .. is the unquoted form of the syntax.
Examples
On UNIX platforms,
cd('/usr/local/matlab/toolbox/control/ctrldemos')
changes the current working directory to ctrldemos for the Control System
Toolbox.
On WindowsR platforms,
cd('c:/matlab/toolbox/control/ctrldemos')
changes the current working directory to ctrldemos for the Control System
Toolbox. Then typing
cd ..
changes the current working directory to control, and typing
cd ..
again, changes the current working directory to toolbox.
On any platform, use cd with the matlabroot function to change to a
directory relative to the directory in which MATLAB is installed. For
example
cd([matlabroot '/toolbox/control/ctrldemos'])
changes the current working directory to ctrldemos for the Control System
Toolbox.
See Also
dir, fileparts, mfilename, path, pwd, wha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080513/cfd1aaac/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 39256 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080513/cfd1aaac/attachment-0001.jpe
More information about the Bug-octave
mailing list