MATLAB BUILDER JA 2 Guida Utente Pagina 51

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 292
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 50
Creating an Instance of the Class
myprimes Function
The code for myprimes is as follows:
function p = myprimes(n)
% MYPRIMES Returns the primes between 0 and n.
% P = MYPRIMES(N) Returns the primes between 0 and n.
% This file is used as an example for the MATLAB
% Builder for Java product.
% Copyright 2001-2006 The MathWorks, Inc.
if length(n) ~= 1
error('N must be a scalar');
end
if n < 2
p = zeros(1,0);
return
end
p = 1:2:n;
q = length(p);
p(1) = 2;
for k = 3:2:sqrt(n)
if p((k+1)/2)
p(((k*k+1)/2):k:q) = 0;
end
end
p = (p(p>0));
3-5
Vedere la pagina 50
1 2 ... 46 47 48 49 50 51 52 53 54 55 56 ... 291 292

Commenti su questo manuale

Nessun commento