Someone please optimize this code or write is a little different, so that it doesn't take that much time to run. I really need it, I'd appreciate it alot!

1 visualización (últimos 30 días)
close all
format long
caught = false;
w = 1.61803;
while ~caught
w = w + 0.0000010000000000;
N = 100000000;
x = zeros(N, 1);
y = zeros(N, 1);
t = 0;
dt = 1 / (N - 1);
for k = 2:N
xp = t - x(k-1);
yp = 1 - y(k-1);
C = w / sqrt(xp * xp + yp * yp);
xp = C * xp;
yp = C * yp;
x(k) = x(k-1) + dt * xp;
y(k) = y(k-1) + dt * yp;
if (y(k-1) < 1) && (y(k) >= 1)
caught = true;
w
y(k-1);
y(k);
k;
end;
t = t + dt;
end
end
Someone please optimize this code or write is a little different, so that it doesn't take that much time to run. I really need it, I'd appreciate it alot!
  6 comentarios

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Logical 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!

Translated by