Difference between revisions of "Howto"

From GeodesyLab
Jump to: navigation, search
(... and NetCDF?)
(... and NetCDF?)
Line 15: Line 15:
 
=== ... and NetCDF? ===
 
=== ... and NetCDF? ===
 
The MEXNC, SNCTOOLS and toolsUI packages are installed in </code>/usr/local/matlab</code> . A tutorial describes which routines are  
 
The MEXNC, SNCTOOLS and toolsUI packages are installed in </code>/usr/local/matlab</code> . A tutorial describes which routines are  
provided by the SNCTOOLS package: [http://mexcdf.sourceforge.net/tutorial/index.html | http://mexcdf.sourceforge.net/tutorial/index.html].  
+
provided by the SNCTOOLS package: [http://mexcdf.sourceforge.net/tutorial/index.html http://mexcdf.sourceforge.net/tutorial/index.html].  
 
To make use of those, you might have to alter your path:
 
To make use of those, you might have to alter your path:
  

Revision as of 00:53, 12 June 2008

How to do Matlab

... batch processing?

To call Matlab from the command line or a shell script and have it execute a command or a Matlab script call:

matlab -nojvm -nosplash -r [x,y,z]=script -logfile script.log > /dev/null

This must be called in a directory that contains a file script.m. Whatever Matlab usually dumps to its console ends up in the file script.log. To make sure it does not show up in your script output stdout is redirected to /dev/null. The [x,y,z]= part is only necessary if your script returns results which you would want to use somehow.

IMPORTANT: make sure your script contains an 'exit;' as last command! Otherwise this Matlab instance would remain running which might end up with really nasty performance results in a loop statement. If a bunch of matlab scripts are to be executed, compile a master .m-file which calls them (and is the only one that contains the 'exit;'). This way Matlab is not closed and restarted for each script which might gain a significant performance gain.

... and NetCDF?

The MEXNC, SNCTOOLS and toolsUI packages are installed in </code>/usr/local/matlab</code> . A tutorial describes which routines are provided by the SNCTOOLS package: http://mexcdf.sourceforge.net/tutorial/index.html. To make use of those, you might have to alter your path:

addpath('/usr/local/matlab/mexnc');
addpath('/usr/local/matlab/snctools');
javaaddpath ( '/usr/local/matlab/classes/toolsUI-4.0.jar' );
setpref ( 'SNCTOOLS', 'USE_JAVA', true );

How to do Shell

NOTE: Some commands might be specific for csh/tcsh. Adjustments to bash, sh etc should be straightforward.

... arithmetics?

You would want to use the command 'expr' which "evaluates basic expressions" to do basic arithmetics in the Shell. Try something like:

set X=`expr 100 + 50 '*' 3`
echo $X

This should give you 250. The '`' denote that a subshell is opened in which the command expr 100 + 50 '*' 3 is executed. The return value is then stored in the variable X. You can also use variables in your expressions:

set X=`expr $X + 50 '*' 3`
echo $X

This should return 400.

For the reason of '*' being interpreted als wildcard in the Shell the asterisk must be in single quotes: '*' otherwise you get a syntax error. Check

man expr

to find other operators you would want to use. For more sophisticated math you would wanna use awk or Perl scripts.

How to do GMT

How to do CrusDe