Anda di halaman 1dari 1

MATRIZ DE NUMEROS ALEATORIOS

r = rand(5)
N�meros aleatorios dentro del intervalo especificado
r = -5 + (5+5)*rand(10,1)
Enteros aleatorios
r = randi([10 50],1,5)
N�meros complejos aleatorios
a = rand + 1i*rand
Restablecer generador de n�meros aleatorios
s = rng;
r = rand(1,5)
Array 3D de n�meros aleatorios
X = rand([3,2,3])
Especificar el tipo de datos de n�meros aleatorios
r = rand(1,4,'single')
class(r)
Clonar el tama�o de un array existente
A = [3 2; -2 1];
sz = size(A);
X = rand(sz)
Es un patr�n com�n para combinar las dos l�neas anteriores de c�digo en una sola
l�nea:

X = rand(size(A));
Clonar el tama�o y el tipo de datos de un array existente
p = single([3 2; -2 1]);
X = rand(size(p),'like',p)
class(X)
Clonar un array distribuido
p = rand(1000,'single','distributed');
X = rand(size(p),'like',p);
class(X)
classUnderlying(X)
////////////////////////////////

clear all,clear close,clc


%%
%GENERAR UN NUMERO DE 50 NUMEROS ALEATORIOS EN FORMA ASCENDENTE
r = randi([1 50],1,50) % numeros aleatorios enteros
a=sort(r)% forma ascendente
%%---------------------------------------------------------------
%%
%HALLAR EL PROMEDIO DE un VECTOR
A=[0 1 1;0 2 2;0 3 3;0 4 4]
M=mean(A) % promedio de la columna
%%
%EXTRAER A OTRO VECTOR LOS NUMEROS IMPARES
v=[12 3 56 23 21 10 11 18 27 29 76]
impar=v(rem(v,2)==1)
%%
%GENERAR UNA MATRIZ DE NUMEROS ALEATORIOS DE UNA MATRIZ CUADRADA

Anda mungkin juga menyukai