Why does simulation work in Model A (ASWonly) but fail in Model B (ASW + BSW + MCal), though both have the same ASW structure and I use the same script to enable logging?

6 visualizaciones (últimos 30 días)
I have two Simulink models:
  • Model A: ASW only
  • Model B: ASW + BSW + MCal
Both models have identical ASW architecture, identical signal routing, and identical configuration settings (same Simulink subsystems, Stateflow charts, and MATLAB Function blocks).
I use the same MATLAB script to enable signal logging for a predefined list of ASW signals. In Model A, simulation runs fine. In Model B, I get this error:
Simulation failed: The output of 'modelPath/.../Chart' cannot be logged because this block is a Simulink function within Stateflow or a MATLAB Function block. To log this data, log the signal inside of the Simulink function.
Why does this happen only in Model B when the same script and signal names are used, given that both ASW parts and configuration settings are identical?
I have already tried:
  • Using Signal Conversion blocks after these outputs.
  • Writing values to Data Store Memory (DSM) inside the function and logging them outside.
But the error still persists in Model B.
What is the recommended way to log signals from MATLAB Function blocks or Stateflow charts programmatically without manually modifying the model? Is there another best practice for automated signal logging in such cases?
Any guidance on handling this scenario when automating signal logging would be appreciated. Script added below for reference.
%% Enable all selected signal logging in the given Simulink model
% Version 2 (Author): M Santhosh Kumar
%% Model
model = 'A';
% Load model if not already loaded
if ~bdIsLoaded(model)
load_system(model);
end
% List of signal names to log
signalNames = {'%Giving some 20 Signal names'};
% Find all blocks (including under masks and variants)
allBlocks = find_system(model, 'LookUnderMasks', 'all', 'FollowLinks', 'on','MatchFilter', 'FindAll', 'on', 'Type', 'Block');@Simulink.match.allVariants,
% Loop through each block and check its output ports
for i = 1:length(allBlocks)
try
portHandles = get_param(allBlocks(i), 'PortHandles');
outports = portHandles.Outport;
for j = 1:length(outports)
sigName = get_param(outports(j), 'Name');
if ~isempty(sigName) && any(strcmp(sigName, signalNames))
set_param(outports(j), 'DataLogging', 'on');
%set_param(model, 'LogTestpoints', 'on');
fprintf('✅ Logging enabled for signal: %s\n', sigName);
end
end
catch
% Skip blocks without output ports or inaccessible parameters
end
end
%END

Respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by