It is not recommended to access the S-function's input signal for initializing internal information during the mdlInitializeConditions function in Simulink. For non-virtual blocks other than Constant or Initial Condition (IC) the S-function might not be able to read the input signal during initialization phase resulting in unexpected behaviour.
You can work around this by setting an internal flag in mdlInitializeConditions. In mdlOutputs you could check if this flag is set and initialize the work vector with the current input signal. Then unset the flag.
Please note that you have to set ssSetInputPortDirectFeedThrough for the appropriate input when using this workaround, because you are accessing the input signal during the mdlOutputs function.
Attached you can find a simple example showing an S-function that creates a ramp signal based on the initial value from the input signal during initialization of the S-function.
Best Answer