Help on a problem
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Gaëtan Poirier
el 22 de Sept. de 2017
Comentada: Walter Roberson
el 22 de Sept. de 2017
I have this problem and I'm wondering if anyone can help me to figure it out. It goes as follows: write a program to iteratively generate points in two-dimensional space using the following rules:
(x_{n+1},y_{n+1}) =
/ (0.5,0.27*y_n), with 2% probability;
|
| (-0.139*x_n + 0.263*y_n + 0.57, 0.246*x_n + 0.224*y_n - 0.036), with 15% probability;
<
| (0.17*x_n - 0.215*y_n + 0.408, 0.222*x_n + 0.176*y_n + 0.0893), with 13% probability;
|
\ (0.781*x_n + 0.034*y_n + 0.1075, -0.032*x_n + 0.739*y_n + 0.27), with 70% probability.
Start from an initial point (x_1,y_1)=(0.5,0.0). Carry out the iteration at least 30,000 times
0 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Sept. de 2017
for iter = 1: 30000
r = rand() ;
if r < 0.02
....
elseif r < 0.02+0.15
.....
3 comentarios
Walter Roberson
el 22 de Sept. de 2017
x_ = 0.5;
y_ = 0;
for n = 1: 30000
r = rand();
if r < 0.02
y_(n+1) = y_(n) * 0.27*r;
elseif r < 0.02 + 0.15
x_(n+1) = x_(n) -0.139 * r + 0.246 * r;
y_(n+1) = y_(n) + 0.263 * r + 0.224 * r - 0.036;
etc
After all of that you are probably expected to do
scatter(x, y)
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!