MATLAB BUILDER JA 2 Guide de l'utilisateur Page 58

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 292
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 57
3 Programming
Object[] y = null;
try
{
x = new Object[vals.length];
for (int i = 0; i < vals.length; i++)
x[i] = new MWNumericArray(vals[i], MWClassID.DOUBLE);
cls = new myclass();
y = cls.mysum(1, x);
return ((MWNumericArray)y[0]).getDouble(1);
}
finally
{
MWArray.disposeArray(x);
MWArray.disposeArray(y);
if (cls != null)
cls.dispose();
}
}
This version of getsum takes an array of Object as input and converts each
valuetoa
double array. The l ist of double arrays is then passed to the mysum
function, w here it calculates the total sum of each input array.
Code Fragment: Passing a Variable Number of Outputs
When present, varargout arguments are handled in the same way that
varargin arguments are handled. Consider the following M-function:
function varargout = randvectors
% RANDVECTORS Returns a list of random vectors.
% VARARGOUT = RANDVECTORS Returns a list of random
% vectors such that the length of the ith vector = i.
% This file is used as an example for the MATLAB
% Builder for Java product.
% Copyright 2001-2006 The MathWorks, Inc.
for i=1:nargout
3-12
Vue de la page 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 291 292

Commentaires sur ces manuels

Pas de commentaire