xyRange=[1,5]; %// Starting xy range of particles
numP=3; %// Number of particles generated each day
vx=0.6; vy=0.4; %// x and y velocity
X=[]; Y=[]; %// Vectors start out empty
for day=1:10 %// Generate 3 particles and add to end of vectors X and Y
X=[X;randi(xyRange,numP,1)]; Y=[Y;randi(xyRange,numP,1)]; %// Move all the particles
X=X+vx; Y=Y+vy; end plot(X,Y,'kd'); grid on ; axis([1,50,1,50]); function [box] = coord(X,Y) for j = floor(X/5)+1; k = floor(Y/5); box = k*10+j; end end
MATLAB: How do i remove this error? Function definitions are not permitted in this context.
matlab cvst
Related Question
- How to write matlab program of following equation.
- I’m trying to take the grid points x and y and the velocities Vx and Vy to plot the streamlines using streamline starting at x = −4 and 21 and y locations between -4 and 4.
- Use of ode45 for projectile trajectory including drag
- Plotting two variables from a loop
- How to create a plot with this code
Best Answer