I have a Simulink model that is currently being run from a script (i.e. not a function). The script writes variable values to the MATLAB workspace, runs the model simulation
You can use the evalin() function to execute from your own function a MATLAB expression (as a string) in a specific workspace, in your case the 'base' for SIMULINK to find them. However, if you do not want to use the workspace directly then you can load and save the signals or variables from/to MAT files using the From/To File blocks.