Borrar filtros
Borrar filtros

Get data from parsim (different variables)

10 visualizaciones (últimos 30 días)
Artjom Vartanyan
Artjom Vartanyan el 24 de Abr. de 2024
Respondida: Namnendra el 28 de Jun. de 2024 a las 11:49
Hello,
I got a lot of data from a battery ECM model I parsimmed using different variables: initial SOC, temperatures and C-rates.
As you can see in the screenshot above each simulation has a specific set of [SOC, Temperature, current].
Each of the simulations has an end temperature and an end time, I need to access these variables using a loop.
My question is the following: how can I get those variables?
Thank you

Respuestas (1)

Namnendra
Namnendra el 28 de Jun. de 2024 a las 11:49
Hello Artjom,
To access the end temperature and end time from each simulation in a `parsim` (Parallel Simulink Simulation) run, you need to loop through the results and extract the required data. Assuming that the results are stored in a `Simulink.SimulationOutput` array, you can use the `get` method to access the logged data.
Here is a step-by-step guide on how to achieve this:
1. Run the Simulations: Make sure you have run the simulations using `parsim` and stored the results in a variable, say `simOut`.
2. Extract the End Temperature and End Time: Loop through the `simOut` array and extract the necessary variables.
Here is an example MATLAB script to illustrate this process:
% Assuming simOut is the array of Simulink.SimulationOutput objects
% obtained from the parsim command
% simOut = parsim(...);
% Preallocate arrays to store end temperature and end time
numSimulations = length(simOut);
endTemperatures = zeros(numSimulations, 1);
endTimes = zeros(numSimulations, 1);
for i = 1:numSimulations
% Access the simulation output object
simOutput = simOut(i);
% Assuming the temperature and time are logged in the simulation output
% For example, if they are logged as 'temperature' and 'time'
temperatureData = simOutput.logsout.get('temperature').Values.Data;
timeData = simOutput.logsout.get('time').Values.Data;
% Extract the end temperature and end time
endTemperatures(i) = temperatureData(end);
endTimes(i) = timeData(end);
end
% Display the results
disp('End Temperatures:');
disp(endTemperatures);
disp('End Times:');
disp(endTimes);
Key Points:
1. Access the Simulation Output: Each element in the `simOut` array is a `Simulink.SimulationOutput` object. You can access the logged data using the `logsout` property.
2. Extract Logged Data: Use the `get` method on the `logsout` object to retrieve the logged data. Ensure that the names used in the `get` method match the names used in your model for logging the temperature and time.
3. Retrieve the Last Element: The `end` keyword in MATLAB allows you to access the last element of an array. This is useful to get the end temperature and end time.
Example Model Logging Setup:
Ensure that your Simulink model is set up to log the temperature and time variables. You can do this by using `To Workspace` blocks or the `Signal Logging` feature in Simulink.
Additional Tips:
- Check Variable Names: Ensure that the variable names used in the `get` method match exactly with the names used in your Simulink model.
- Handle Errors: Add error handling to manage cases where the expected data might not be present in the simulation output.
By following these steps, you should be able to extract the end temperature and end time from each simulation in your `parsim` run.
I hope the above information helps.
Thank you.

Categorías

Más información sobre Run Multiple Simulations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by