User`s manual
Examples of Fortran MEX-Files
3-25
Entering these numbers at the MATLAB prompt
x = [3 - 1i, 4 + 2i, 7 - 3i]
x =
3.0000 - 1.0000i 4.0000 + 2.0000i 7.0000 - 3.0000i
y = [8 - 6i, 12 + 16i, 40 - 42i]
y =
8.0000 - 6.0000i 12.0000 +16.0000i 40.0000 -42.0000i
and invoking the new MEX-file
z = convec(x, y)
results in
z =
1.0e+02 *
Columns 1 through 4
0.1800 - 0.2600i 0.9600 + 0.2800i 1.3200 - 1.4400i
3.7600 - 0.1200i
Column 5
1.5400 - 4.1400i
which agrees with the results the built-in MATLAB function conv.m produces.
Dynamically Allocating Memory
It is possible to allocate memory dynamically in a Fortran MEX-file, but you
must use
%val to do it. This example takes an input matrix of real data and
doubles each of its elements.