Please see the section User Parameters in the chapter C-Scripts in the user manual to learn how to pass MATLAB/Octave expressions (including workspace variables) into C code. The section Multiple Sample Times - Turn-on Delay further below in the same chapter presents a small example implementation.
Alternatively you could also consider using the workspace variable in a Constant block and feed its output signal into the C-Script block.