O'Reilly logo

Introduction to Numerical Electrostatics Using MATLAB by Lawrence N. Dworsky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

AInterfacing with Other Languages

(Note: The MATLAB coding described in this appendix has been tested on a Windows 7 computer. The equivalent system calls should work on a Unix or Mac computer, but have not been tested.)

Sometimes it is desirable to perform some calculations in a language other than MATLAB. Possible reasons for this are that (1) a complicated, working, calculation program already exists; or (2) it is difficult or even impossible to vectorize a MATLAB program but desirable to utilize the calculation speed of some fully compiled optimized code in a language such as C or FORTRAN.

MATLAB has built-in capabilities for doing this.1,2 The MATLAB capabilities are significant and merit investigation if this type of interface is desired. There are limitations, however, as to what compilers and languages are supported. The technique described in this appendix is a “quick and dirty” patch that works well provided you can write or modify and compile code with a compiler and language of your choice into an executable program.

The procedure is very straightforward and utilizes MATLAB's capability of executing a system command and then waiting for its completion:

  • 1 Prepare data in MATLAB using whatever script or functions are necessary.
  • 2 Save the necessary data to a file.
  • 3 Execute the external program.
  • 4 The external program reads the data file, does its work, and writes its results to a second data file. The external program may open and read and/or write other files if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required