Can not call the system command in matlab

192 views
Skip to first unread message

Tom

unread,
Jul 27, 2016, 12:06:09 AM7/27/16
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise
Hi all,
    I use VirtualBox and run Ubuntu12.04 on this virtual machine.  Matlab 2013 and GMT4.5.8, StaMPS_v3.3b1 and TRAIN_2beta were used on my computer. When I used TRAIN to process the MERIS and MODIS data, the commands from GMT , Python and SHELL was called in Matlab by using 'system' command. However, the matlab failed to call those 'system' commands. It is OK by runing  the GMTcommand from the terminal itself, but this would be very time-consuming and less automatic processing. Anybbody knows how to fix this problem? Very appreciate for any idea about this.
 Tom
Regards

Ahmad

unread,
Jul 27, 2016, 10:31:35 AM7/27/16
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise

Hi,

You should just set the library path into your ".cshrc" file.
something like this:
setenv LD_LIBRARY_PATH /usr/lib

Regards
A.H

David Bekaert

unread,
Jul 27, 2016, 10:41:09 AM7/27/16
to TRAIN_...@googlegroups.com
Hi,

Thanks for your question.
The system function is specific to the operating system.
Currently I have not tested it for ubuntu.
You could run all the system calls manually, but it will be a tedious process.

I suggest you first try the suggestion by Ahmad.

If that does not work then we could try to dig into the problem further.
In matlab type the following command and send the generate command line output back.

system('ls')
system('gmt')
system('psxy')

Cheers,
David






--
You received this message because you are subscribed to the Google Groups "TRAIN - Toolbox for Reducing Atmospheric InSAR Noise" group.
To unsubscribe from this group and stop receiving emails from it, send an email to TRAIN_suppor...@googlegroups.com.
To post to this group, send email to TRAIN_...@googlegroups.com.
Visit this group at https://groups.google.com/group/TRAIN_support.
To view this discussion on the web visit https://groups.google.com/d/msgid/TRAIN_support/b3972a38-15f3-4295-8ff2-a3043d8b3a15%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tom

unread,
Jul 28, 2016, 10:22:34 AM7/28/16
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise
Hi Ahmad,
    I tried this on my computer. Because I use BASH, so in my case I set it: export LD_LIBRARY_PATH=/usr/lib.
But it didn't work. When called the system commands in Matlab, it failed without any error messages.
    Anyway, thank you for your reply.

在 2016年7月27日星期三 UTC+8下午10:31:35,Ahmad写道:

Tom

unread,
Jul 28, 2016, 10:29:32 AM7/28/16
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise
Dear David,
    I have tried Ahmad's way, it didn't work.
    I test it with system('ls'), it works, list all the files in the folder within matlab, but it failed with commands "system('gmt')
, system('psxy')" and gave error messages "Cannot find this command".
   When downloaded MODIS data using python commands, 
    commandstr = ['python $get_modis_filepath -r ' num2str(lonmin) '/' num2str(lonmax) '/' num2str(latmin) '/' num2str(latmax) ' -t ' datestr(dates(k),'yyyy-mm-dd') 'T' UTC_sat ':00 -p terra -v -o OSCAR_Modis_' datestr(dates(k),datestructure) '.grd -f -v > download.log' ];
   [a,b] = system(commandstr);
   It also didn't work, and the error messages are: 
   Unknown option: -r
  Unknown option: -r
  usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
  Try `python -h' for more information.

在 2016年7月27日星期三 UTC+8下午10:41:09,David Bekaert写道:

David Bekaert

unread,
Jul 28, 2016, 10:36:28 AM7/28/16
to TRAIN_...@googlegroups.com
Hi,

When you are in your regular linux command line can you call the gmt executables?
e.g. exit matlab
> gmt
> psxy
I believe you need to add the gmt bin folder to your .bashrc start-up file.
Once that works you should be able to call them from within matlab too.

Python seems already to be an executable from within matlab as it gave you a python error.
However, I believe the path to OSCAR download script might not be set.
You might have some similar issue with the ECMWF api.
You can se these either in the APS_CONFIG.bash or in your original .bashrc file.

Hope this helps,
Cheers,

David


Ahmad

unread,
Jul 29, 2016, 3:05:35 PM7/29/16
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise
Hi Tom,

By "/usr/lib" I meant the path your "libgmt.a" or "libgmt.so" files are.
Anyway, as David said, first check you set gmt bin path in your ".bashrc" or not.
Then, try
>>!psxy 
in matlab and see if it calls the command?

Sincerely
A.H

Tom

unread,
Aug 4, 2016, 10:49:20 PM8/4/16
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise
Hi David and Ahmad,
    Sorry to response to you later but i was working on it. I tried many methods as you gave me and also the methods by Googgle. I have changed my Matlab to R2014b and found it was not the version problem. Finally, I found that on my computer I can only launch my Matlab by using " sudo matlab"  on the terminal. If I didn't use 'sudo' in front of 'matlab', maltab were failed to launch, and errors were posted like this:
Fatal Error on startup: Cannot locate or initialize class com/mathworks/jmi/OpaqueJavaInterface.
java.lang.UnsupportedClassVersionError: com/mathworks/jmi/OpaqueJavaInterface : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
"
I think it is the java version probelm on my computer due to the higher version of Matlab, i tried to find solutions by Google, but all of them didn't work.
So I need to launch my matlab by using 'sudo' each time, and by doing this, i found the environment variable 'PATH' from matlab (system('echo $PATH')) and from terminal (echo $PATH) are different. This is the probelm why i can not call the GMT commands in the matlab. So I fixed this prpblem by linking  my GMT commands into the matlab's PATH. And it worked, I can call the GMT commands in matlab now.


在 2016年7月30日星期六 UTC+8上午3:05:35,Ahmad写道:

Saeed Zanjani

unread,
May 26, 2017, 2:24:41 PM5/26/17
to TRAIN - Toolbox for Reducing Atmospheric InSAR Noise
Hi Tom

How did you link your GMT commands into the matlab's PATH?


Very appreciate for any idea about this.

Saeed
Reply all
Reply to author
Forward
0 new messages