A Question about Simulink



I am building a discrete time system in Simulink, and one input is from Matlab code. What I want to do is: for each clock phase, I need to use the matlab code to generate an input and feed into simulink, and there are some outputs generated in simulink and put into matlab code again for each clock phase. That means, the .m file and simulink operates at the same time. Can I do that? How should I implement this? Thank you very much for your kind help!
.