Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using MATLAB system command instead of CYGWIN

293 views
Skip to first unread message

M

unread,
Jul 25, 2013, 5:43:09 PM7/25/13
to
Hello, I have CYGWIN installed and can successfully run the following commands from the CYGWIN terminal:
ls /cygdrive/c/nrn73/bin
cd /cygdrive/c/nrn73/bin
/cygdrive/c/nrn73/bin/mknrndll

However, I get different results if I run these in MATLAB using the system command:
>> system('ls /cygdrive/c/nrn73/bin/') % somewhat successful; prints out all the files in the directory except those with the .dll extension

>> system('cd /cygdrive/c/nrn73/bin/') % doesn't work
The system cannot find the path specified.

ans =

1

>> system('/cygdrive/c/nrn73/bin/mknrndll') % doesn't work
The system cannot find the path specified.

ans =

1

I don't need ls to print out all the .dll files when executed from MATLAB, but I do need cd to work, and I need to be able to run the executable mknrndll from MATLAB. Any idea what I'm doing wrong? Why does ls work but not cd in MATLAB?

Chris

unread,
Jul 26, 2013, 10:05:24 AM7/26/13
to
I can provide a little guidance: generally DOS commands from matlab are not "sticky" that is the behavior is like calling a function: variables generated in the function usually have local scope. That means that two sequential calls like you intend to do will probably not serve the intended purpose. You can instead try writing a DOS batch file and calling that form matlab.

M

unread,
Jul 26, 2013, 12:40:40 PM7/26/13
to
Hi Chris, thanks for your reply. I want to clarify that I don't count on stickiness here, I really only need to run the last command and it should stand alone. I provided the output of the other two commands just to provide more information. I do intend for these commands to all be run independently or not at all.

That said, your recommendation of writing another file with the command and calling that from MATLAB works. So what I've done now is create a file mycmd.exe that contains:

/cygdrive/c/nrn73/bin/mknrndll

Then from MATLAB, I call:
>> system('sh mycmd.exe')

And now it will run. Thank you for your assistance!

"Chris " <cfw...@yahoo.com> wrote in message <kstvn4$gfp$1...@newscl01ah.mathworks.com>...

Chris

unread,
Jul 26, 2013, 1:16:07 PM7/26/13
to
Nice solution! Much better than what I suggested.
0 new messages