hello
i've trying to generate a random number inside a function, but to no avail.
I've done the usual
Code:
void motion( int initial_position, float carrier_position[200],float x)// equation of motion in 1D. In nm
{
int counter;
double bulk_time=100e-12; //carrier decay time in Bulk AlGaAs
double velocity=2e13; // carrier speed in bulk GaAs
srand((unsigned)time(NULL));
x = (float) rand()/RAND_MAX;
for(counter=1;counter<=101;counter++)// 101 steps cover 2000 nm at 2e13 nm/s and 1ps time step
{
carrier_position[counter]=(float)initial_position+velocity*x*(time_step*counter-1e-12);
}
}
i've tried generating x inside the for loop, with srand outside as well, but to no avail.
I also tried generating the seed before calling the function in the main program
any ideas?
TIA