This example code shows how to use the
simulink.compiler.getSimulationOutput function to get the
Simulink.SimulationOutput while the deployed simulation is
executing.
Create the Simulink.SimulationInput object for the model.
in = Simulink.SimulationInput(model);
Set model parameters for the model.
in = in.setModelParameter('SimulationMode', 'Rapid');
in = in.setModelParameter('SaveOutput', 'on');
in = in.setModelParameter('SaveFormat', 'Dataset');
in = in.setModelParameter('StopTime', 'Inf');
Configure the mode and time for the simulation.
tmr = timer('Name','PartialSimOut','ExecutionMode','singleShot','StartDelay', 30);
tmr.TimerFcn = @(~,~) partialSimOutFcn(test, model);
% Start and run the simulation for 30 seconds
tmr.start();
% Simulate
out = sim(in);
tmr.stop();
tmr.delete();
Function to get a partial simulation output.
function u = partialSimOutFcn(test, model)
% Get the sim output after the first 30 seconds of sim
simOut = simulink.compiler.getSimulationOutput(model);
% Stop the simulation
simulink.compiler.stopSimulation(model);
end
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.