Documente Academic
Documente Profesional
Documente Cultură
aleatorios
PROYECTO 2 : FRACTALES
x = rand (1000000,1);
h = histogram (x);
Código:
clear all;
x=0;
y=0;
P = [0;0];
T1 = [0 0;0 0.16];
T2 = [0.85 0.04;-0.04 0.85];
T3 = [0.2 -0.26; 0.23 0.22];
T4 = [-0.15 0.28;0.26 0.24];
S1=[0;1.6];
S2=[0;0.44];
tiempo_inicio = cputime;
for i = 1:10000
U = rand;
if U < 0.01;
P = T1 * P;
elseif U >= 0.01 & U < 0.86
P = T2 * P + S1;
elseif U >= 0.86 & U < 0.93
P = T3 * P + S1;
else
P = T4 * P + S2;
end
x = P(1);
y = P(2);
hold on;
p = plot(x,y);
p.Marker = '.';
end
Código:
clear all;
x=0;
y=0;
P = [10;10];
T1 = [0.745455 -0.459091;0.406061 0.887121];
T2 = [-0.424242 -0.065152;-0.175758 -0.218182];
S1=[1.460279;0.691072];
S2=[3.809567;6.741476];
tiempo_inicio = cputime;
for i = 1:10000
U = rand;
if U <= 0.912675;
P = T1 * P + S1;
else
P = T2 * P + S2;
end
x=P(1);
y=P(2);
hold on;
p = plot(x,y);
p.Marker = '.';
end
tiempo_inicio = cputime;
for i = 1:10000
U = rand;
if U <= 0.787473
P = T1 * P + S1;
else
P = T2 * P + S2;
end
x=P(1);
y=P(2);
hold on;
p = plot(x,y);
p.Marker = '.';
end
Codigo:
clc;
clear all:
close all;
hold on;
N = 10000000;
x = zeros(1,N);
x = y ;
tiempo_inicio = cputime;
for i = 2 : N
U = randi([0 2]);
switch U
case 0
x(i) = 0.5*x(i-1) + 1;
y(i) = 0.5*y(i-1) + 1;
case 1
x(i) = 0.5*x(i-1) + 1;
y(i) = 0.5*y(i-1) + 50;
case 2
x(i) = 0.5*x(i-1) + 50;
y(i) = 0.5*y(i-1) + 50;
end
end
p = plot(x,y,'.');
tiempo_inicio = cputime;
for i = 1:100000
U = rand;
if U < 0.25;
P = T1 * P + S1;
elseif U >= 0.25 & U < 0.5
P = T2 * P + S2;
elseif U >= 0.5 & U <0.75
P = T3 * P + S3;
else
P = T4 * P + S4;
end
x=P(1);
y=P(2);
hold on;
p = plot(x,y);
p.Marker = '.';
end
Código:
clear all;
x=0;
y=0;
P = [0;0];
T1 = [0 -0.5;0.5 0];
T2 = [0 0.5;-0.5 0];
T3 = [0.5 0;0 0.5];
S1=[0.5;0];
S2=[0.5;0.5];
S3=[0.25;0.5];
tiempo_inicio = cputime;
for i = 1:10000
U = rand;
if U < 0.333333;
P = T1 * P + S1;
elseif U >= 0.333333 & U < 0.6666666
P = T2 * P + S2;
else
P = T3 * P + S3;
end
x=P(1);
y=P(2);
hold on;
p = plot(x,y);
p.Marker = '.';
end
En 1985, M. F. Barnsley, justamente el creador del juego del caos, generalizó más el método
desarrollando lo que hoy conocemos como IFS (Iterated Function Systems). Vamos paso a
paso para entender esta nueva forma de obtener fractales.
Observa el monigote inicial de la tabla inferior. Llamémoslo semilla inicial. Sobre él vamos a
ejercer una serie de transformaciones. Creamos tres copias reducidas a 1/3 y las situamos
como se observa en la segunda celda. Repetimos el procedimiento con cada nuevo monigote
y ...