MATLAB BUILDER JA 2 Podręcznik Użytkownika Strona 56

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 55
3 Programming
y = sum([varargin{:}]);
This function returns the sum of the inputs. The inputs are provided as a
varargin argument, which means that the caller can specify any num ber of
inputs to the function. The result is returned as a scalar
double.
Code Fragment: Passing Variable Numbers of Inputs
Jav a Builder generates a Java interface to this function as follows:
/* mlx interface - List version*/
public void mysum(List lhs, List rhs)
throws MWException
{
(implementation omitted)
}
/* mlx interface - Array version*/
public void mysum(Object[] lhs, Object[] rhs)
throws MWException
{
(implementation omitted)
}
/* standard interface - no inputs */
public Object[] mysum(int nargout) throws MWException
{
(implementation omitted)
}
/* standard interface - variable inputs */
public Object[] mysum(int nargout, Object varargin)
throws MWException
{
(implementation omitted)
}
In all cases, the varargin argument is passed as type Object.Thislets
you provide any number of inputs in the form of an array of Object, that
is
Object[], and the contents of this array are passed to the compiled
3-10
Przeglądanie stron 55
1 2 ... 51 52 53 54 55 56 57 58 59 60 61 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag