Option 1: Disable DataLogging programmatically
You can disable signal logging for all signals using the following code (replace 'gcs' with your model name if needed):
mdlsignals = find_system(gcs,'FindAll','on','LookUnderMasks','all','FollowLinks','on','type','line','SegmentType','trunk');
ph = get_param(mdlsignals,'SrcPortHandle');
for i=1: length(ph)
set_param(ph{i},'DataLogging','off');
end
To disable signal logging across an entire Simulink model, including any library-linked sub-models, referenced models, reference and library models within variant subsystems, see:
Option 2: Consider Signal Logging Override
Alternatively, consider using Signal Logging Override. This lets you temporarily disable all logging via the Signal Logging Selector, and easily revert to your original settings later.
To access it, open the Simulink Toolstrip, go to the Simulation tab, then Prepare > Configure Logging, and click "Configure Signals to Log." At the top of the dialog, select "Override signals" and use Ctrl+A to select all signals on the right and disable DataLogging: You can also configure how model references behave here. To restore your original setup, simply switch back to "Log all signals as specified in model."
If your model includes subsystems or model references, the UI workflow can be cumbersome since you need to go through each one individually. In such cases, you can automate the process programmatically: