This can be done by utilizing the External Mode triggering feature. In the model, just leave the Analog Input (or whatever) block outside any triggered or enabled subsystem, so that it measures the data for the whole duration of the experiment. Then, use External Mode to only log the intervals you are interested in.
To do this, go to Code, External Mode Control Panel, Signal & Triggering. There, select the Duration parameter so that it corresponds to 30 seconds - e.g., for sample rate of 1 kHz, that would be 30.000 samples, so you would set this as Duration. Then, set the Mode to one-shot, so that data logging stops and is not re-triggered after one buffer of data is collected. Finally, deselect Arm when connecting to target so that data logging does not start immediately after the model is started, and close the GUI.
Then, build and run your model, leaving the External Mode Control Panel open. Every time you want to log the data, press the Arm Trigger button and you'll get one buffer of data. If you prefer to build your own GUI instead, command-line equivalents of setting the External Mode parameters and arming the trigger do exist.
You may also want to take a look at the Data Archiving feature that allows you to automatically save the captured data buffers into MAT-files with auto-incremented names, so you don't need to take care of reading the captured buffer from workspace.
And, if you want to automate the process further, you may set External Mode to start the logging automatically when some signal crosses a specified value, and this can also include pre-trigger (start logging before the trigger event occurs). Please see the documentation for more information on that.
Best Answer