Can I use Simulink.SimulationInput to manage DataLogging for Outports
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a large model that I want to turn on DataLogging only for signals of particular interest in a given simulation.
I am already using the Simulink.SimulationInput object to modify e.g. model workspace parameters, which is conventient because the original model stays the same.
However, the only way I have found to modify the DataLogging state of signals is to load the model, find a given Outport handle and do
>> set(outPortHandle, 'DataLogging', 'on');
The problem is that this puts the model into a modified state, and I can only close afterwards by force and discard other possible changes.
So in short I would like to use SimulationInput object to do something like
>> simIn.setBlockParameter('TopModel/Subsystem/Block.PortHandles.Outport(2)', 'DataLogging', 'on');
but the syntax only allows me to access the Block attributes on top level?
5 comentarios
Paul
el 28 de Mzo. de 2024
Thanks for showing your method. I was using Simulink.SimulationInput with a set_param command in the PreSimFcn to turn off data logging for specified signal, and that was causing the model to become dirty.
Respuestas (1)
Rasmita
el 11 de Abr. de 2023
Hi Mats,
It is my understanding that, you want to turn on 'DataLogging' only for signals of particular interest using 'SimulationInput' object. Unfortunately, it is not possible to set the 'DataLogging' state of a signal using the ‘setBlockParameter’ method of the ‘Simulink.SimulationInput‘ object. This is because the 'DataLogging' state is an attribute of the block port, not the block itself.
You can use the ‘Simulink.BlockDiagram.modifyTunableParameters’ function to modify the 'DataLogging' properties of the blocks corresponding to the signals of interest. Here is an example:
% Specify the paths to the signals you want to enable DataLogging for
signalPaths = {'myModel/Signal1', 'myModel/Signal2', 'myModel/Signal3'};
% Get the handles of the blocks corresponding to the signals of interest
blockHandles = cell(length(signalPaths), 1);
for i = 1:length(signalPaths)
blockHandles{i} = get_param(signalPaths{i}, 'Handle');
end
% Create a structure with the DataLogging properties to set for each block
dataLoggingProperties = struct('DataLogging', {'on'});
% Modify the DataLogging properties of the blocks using modifyTunableParameters
Simulink.BlockDiagram.modifyTunableParameters(blockHandles, dataLoggingProperties);
This approach modifies the 'DataLogging' properties of the blocks directly in the model but does not modify the original model itself. However, any changes made to the original model after running this code snippet may overwrite the 'DataLogging' properties set in this way.
For information, refer below documentation:
Hope this helps.
Regards,
Rasmita
3 comentarios
Paul
el 11 de Abr. de 2023
Is there a doc page for Simulink.BlockDiagram.modifyTunableParameters? I couldn't find it.
I did find it mentioned on Code Regeneration in Accelerated Models, but it was just plain text, not a link to doc page.
Ver también
Categorías
Más información sobre Save Run-Time Data from Simulation 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!