MATLAB: Matlab loop as input in simulink

matlab simulink function

I have a for loop in a matlab script and i want use it as a real time input in simulink. any ideas?

Best Answer

For that purpose, you may use From Workspace block but most importantly, you need to provide your workspace data with a time data which will imitate Simulink's time vector so that Simulink will not throw an error. See the attached model, run it and see the results. The necessary code is written in File->Model Properties->Model Properties->PreLoadFcn.