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

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

- ServerfaultXchanger
- SuperuserXchanger
- UbuntuXchanger
- WebappsXchanger
- WebmastersXchanger
- ProgrammersXchanger
- DbaXchanger
- DrupalXchanger
- WordpressXchanger
- MagentoXchanger
- JoomlaXchanger
- AndroidXchanger
- AppleXchanger
- GameXchanger
- GamingXchanger
- BlenderXchanger
- UxXchanger
- CookingXchanger
- PhotoXchanger
- StatsXchanger
- MathXchanger
- DiyXchanger
- GisXchanger
- TexXchanger
- MetaXchanger
- ElectronicsXchanger
- StackoverflowXchanger
- BitcoinXchanger
- EthereumXcanger