mardi 6 juillet 2021

how to generate random coordinates matlab

I am trying to generate random coordinates to release particles in a particle tracking model. I release particles every hour within the model, and want to generate different release coordinates at each particle release.

my code so far:

           numparts = 200; 
           t1 = datenum(2017,3,1);
           t2 = datenum(2017,6,2); 
           PartRelease = t1:hours(1):t2; 

           for i = 1:size(PartRelease)
               lon = (-8 -(-4.5)).*rand(numparts,1) + (-4.5); 
               lat = (58 - 55).*rand(numparts,1) + 55; 
           end 

This gives me a release at random locations, but at the same location each release time. Any suggestions how i can edit this to give me a different set of coordinates each time?

Thanks.




Aucun commentaire:

Enregistrer un commentaire