Data capture rates and Simulink for digital control

Hello I cannot get a straight answer on this and it seems simple. I am a very basic Arduino programmer. However I am a very strong user of Matlab and Simulink and I teach a class in Digital Control Systems. I what to use an Arduino Mega to demonstrate priniciples of Sample-Time control.

That being said I want to use autocode Simulink to do the job. I have got the arduino mega to accept the code and over External (option) I can get a consistant (set by me) sample rate of up to 25Hz. Is that the fastest I can expect? The reason for this is I need to log the data. If I use External Mode I can send it to Matlab workspace and view the data. however 25Hz is really slow with a very basic piece of code. AI in and a scope.

1.) is 25 Hz what is expected using External Mode? 2.) What are my other options to get closer to 100Hz or even 1kHz? Would I have to add an SD card and code that to record the data? 3.) I imagine it is feasible to go faster say 500Hz but NOT in External Model so I cannot see the data live or record it, but if I devise a control scheme (say PID) in autocode it I could see the system run under control but I could not send commands or read anything live. It would just go. that isn't a terrible option if it is just as easy as coding the controller with a AI and a PWM not in External mode and set the sampling time to 0.002 seconds in simulink.

Above all I need a consistant sample time. I would like to log the data and I would like to send setpoints to the arduino from Simulink.

Thanks Jason

It's been a while since I last used MATLAB/Simulink, but to my experience automatically generated code is usually not very efficient. I think to achieve high-speed controls you need to implement the controller in pure C, eventually even without using the arduino libraries, but with direct access to the registers.