Programming and Data Types | ![]() ![]() |
Shell Escape Functions
It is sometimes useful to access your own C or Fortran programs using shell escape functions. Shell escape functions use the shell escape command !
to make external stand-alone programs act like new MATLAB functions. A shell escape M-function is an M-file that:
For example, look at the code for garfield.m
, below. This function uses an external function, gareqn
, to find the solution to Garfield's equation.
function y = garfield(a,b,q,r) save gardata a b q r !gareqn load gardata
a
, b
, q
, and r
to a MAT-file in the workspace using the save
command.
gareqn
that uses the workspace variables to perform its computation. gareqn
writes its results to the gardata
MAT-file.
gardata
MAT-file to obtain the results.
![]() | Obtaining User Input | Optimizing MATLAB Code | ![]() |