MATLAB: How to control a contant/ trigger signal in simulink FROM an m-file

simulink

Hi! I'm using an m file to control a simulation (simulink slx file). The user enters the stop time. When the simulation time reaches its half value, (ie halfway through the simulation,) I need to change a constant from 0 to 1. when it reaches 75%, I need to change the (same) constant source from 1 to 0.
so my question is, how do we control the value of the constant block (or any other block that can produce a const, eg. a step block, or signal generator) with respect to the simulation time from an m file?
Please help me.. I googled a lot but couldn't find a solution thanks

Best Answer

oh I myself found the soln :) kinda dumb of me ;)
you simply need the FROM WORKSPACE block. enter a 2-columned matrix in it, 1st column contains time with respect to stop time and 2nd contains const values........
not removing this question in case anybody needs it