how to store particle locations in a simulation in Matlab determined by velocity

by Nic   Last Updated May 23, 2020 00:01 AM - source

I am trying to simulate particles determined by velocity. I want to store the present particle location, and step forward by velocity in time, so I can plot the track of the all the particles.

This is the code I have, but it doesn't update the particle positions.

Any help would be great.

dt = .1;
t = 1;

while t < max(time) - dt

t = t+1;

% set present particle location 
x(t,:) = x(t-1,:);
y(t,:) = y(t-1,:);

% interpolate velocity with the present location
int_u = interp2(lon2d,lat2d,u2d,x(t-1,:),y(t-1,:));
int_v = interp2(lon2d,lat2d,v2d,x(t-1,:),y(t-1,:));

% take the previous position of the particle and step forward

xtrack(t,:) = x(t-1,:) + int_u;
ytrack(t,:) = y(t-1,:) + int_v;

end



Related Questions




Constellation for 8-PSK Modulation

Updated October 19, 2019 19:01 PM

MATLAB Simulink: Exceed 1000 non virtual block limit

Updated August 12, 2019 03:01 AM

Simulink Error: more than 1000 non-virtual blocks

Updated August 12, 2019 18:01 PM