How to send data from while loop during each iteration to simulink sub system model

I am having a while loop in Particle swarm optimization controller (written in embedded matlab code). The controller should send an updated data to the simulink sub system. this updation is done by iterating while loop. Until the while loop finishes i couldnt send the data, I tried with eliminating while loop, but the optimization program has to be iterated some way