Using system command in matlab

Vincent Zhang Lv1

When you want to use the system command in matlab, for example, if you want to use the ls command in matlab, you can use the following code:

1
[status,cmdout] = system('ls -l');

Or you can use the following code:

1
!ls -l

However, sometines these commands will not work, especially you are use matlab in MacOS. In this case, you can use the following code:

1
setenv('PATH', [getenv('PATH') ':/path/to/your/command']);

To obtain the path of your command, for example, the python command, you can use the following code:

1
which python

Or you can use the following code to obtain the path of all commands:

1
echo $PATH

That is all.

  • Title: Using system command in matlab
  • Author: Vincent Zhang
  • Created at : 2024-01-21 14:13:57
  • Updated at : 2024-01-22 14:02:29
  • Link: https://aipikachu.me/posts/8264bda9/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
Using system command in matlab