Programming and Graphics

(Kiana) #1

288 Introduction to C++ Programming and Graphics


In this chapter, we explain howMatlabcan be called from C++ code
for the purpose of using theMatlabmathematical functions and generating
graphics. The converse, calling C++ functions from aMatlabcode, is also
possible, though of limited interest to the C++ programmer.


9.1 InvokingMatlab


To invokeMatlabin Windows, we double-click on theMatlabicon. This
runs a starter program, currently a disk operating system (DOS) batch script,
that launches the mainMatlabexecutable. Alternatively, we can startMat-
labfrom a DOS command line by a procedure similar to that discussed next
for Unix.


To invokeMatlabin Unix, we run the Unix scriptmatlabby issuing
the command:


matlab

Assuming that the script is in the execution path, this will launchMatlabex-
ecutable in some graphical used interface (GUI) or command line mode. To
suppress the memory consuming GUI, we issue either the command:


matlab -nodesktop

or the command:


matlab -nojvm

wherejvmis an acronym for java virtual machine. StartingMatlabby issuing
the command:


matlab -nodesktop -nosplash

suppresses both the GUI and the splash screen during start-up.


In Unix,Matlabcan be launched with a number of options. To obtain
a list accompanied by explanations, we request help by issuing the command:


matlab -help

Matlabuses a number of shared libraries, parameters, and environmen-
tal variables. To obtain a list, we issue the command:


matlab -n
Free download pdf