How do I use hist3 with my code?

1 vue (au cours des 30 derniers jours)
Delshad Ayoubi
Delshad Ayoubi le 3 Mar 2018
In this code, I'm plotting a lot of particles and I want to represent them visually in a hist3 plot. I don't know how to make it work, it keeps on plotting one particle only, I want to put all of them in the 9x9 hist3 plot.
clear
clc
N = 30;
M = 40;
%--------------Cirkeln--------------
radie = 50;
x=0;
y=0;
theta=linspace(0,2*pi);
%-----------------------------------
x_t = zeros(M, N+1);
y_t = zeros(M, N+1);
tic
for n = 1:N
for m = 1:M
distance = inf;
while distance > radie % So that they do not pass the circle.
x_t(m, n+1) = x_t(m, n) + (-1).^randi(2);
y_t(m, n+1) = y_t(m, n) + (-1).^randi(2);
distance = hypot(x_t(m, n+1), y_t(m, n+1));
end
end
plot(x_t(:, 1:n+1)', y_t(:, 1:n+1).','.', 'MarkerSize', 5);
hold on
plot(x+radie*cos(theta),y+radie*sin(theta));
axis equal
hold off
drawnow
hist3([x_t(m, n) y_t(m, n)],[9 9])
end
toc
grid on
%hist3([x_t(m,n+1) y_t(m,n+1)])

Réponses (0)

Catégories

En savoir plus sur Just for fun dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by