MATLAB BUILDER JA 2 Guida Utente Pagina 58

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 292
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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
Vedere la pagina 57
1 2 ... 53 54 55 56 57 58 59 60 61 62 63 ... 291 292

Commenti su questo manuale

Nessun commento