| External Interfaces Reference |    | 
Evaluate MATLAB function in server
MATLAB Client
result = h.Feval('functionname', numout, arg1, arg2, ...)
result = Feval(h, 'functionname', numout, arg1, arg2, ...)
result = invoke(h, 'Feval', 'functionname', numout, ...
arg1, arg2, ...)
Method Signatures
HRESULT Feval([in] BSTR functionname, [in] long nargout, [out] VARIANT* result, [in, optional] VARIANT arg1, arg2, ...)
Visual Basic Client
Description
Feval executes the MATLAB function specified by the string functionname in the Automation server attached to handle h. 
Indicate the number of outputs to be returned by the function in a 1-by-1 double array, numout. The server returns output from the function in the cell array, result.
You can specify as many as 32 input arguments to be passed to the function. These arguments follow numout in the Feval argument list. There are four ways to pass an argument to the function being evaluated. 
Remarks
If you want output from Feval to be displayed at the client window, you must assign a returned value.
Server function names, like Feval, are case sensitive when using the first two syntaxes shown in the Syntax section.
There is no difference in the operation of the three syntaxes shown above for the MATLAB client.
Passing Arguments -- MATLAB Client
This section contains a number of examples showing how to use Feval to execute MATLAB commands on a MATLAB Automation server.
strcat through Feval (strcat deletes trailing spaces; use leading spaces):
clistr that contains the second string:
srvstr is defined in the server, not the client. Putting an equals sign after a variable name (e.g., srvstr=) indicates that it a server variable, and that MATLAB should not expect the variable to be defined on the client:
Visual Basic Client
Here are the same examples shown above, but written for a Visual Basic client. These examples return the same strings as shown above.
strcat on the server:
Dim Matlab As Object Dim out As Object Matlab = CreateObject("matlab.application") out = Matlab.Feval("strcat", 1, "hello", " world")
clistr locally and pass this variable:
Feval Return Values -- MATLAB Client
Feval returns data from the evaluated function in a cell array. The cell array has one row for every return value. You can control how many values are returned using the second input argument to Feval, as shown in this example. 
The second argument in the following example specifies that Feval return three outputs from the fileparts function. As is the case here, you can request fewer than the maximum number of return values for a function (fileparts can return up to four):
Convert the returned values from the cell array a to char arrays:
Feval Return Values -- Visual Basic Client
Here is the same example, but coded in Visual Basic. Define the argument returned by Feval as an Object.
Dim Matlab As Object Dim out As Object Set Matlab = CreateObject("matlab.application") out = Matlab.Feval("fileparts", 3, "d:\work\ConsoleApp.cpp")
See Also
Execute, PutFullMatrix, GetFullMatrix, PutCharArray, GetCharArray
|   | Execute | GetCharArray |  | 
© 1994-2005 The MathWorks, Inc.