I am simulating very large dataset.
The model itself is small but the dataset is large. So, the model will be simulated for million times. It would increase if i reduce the simulation frequency which i would need to do later.
I am already using rapid accelerator mode with RapidAcceleratorUpToDateCheck to off.
But the execution is still slower because of the large dataset. I can try to run on multiple matlab instances as i can see the CPU is not used much, unfortunately i cannot use the parallel computing toolbox.
I would like to focus on the below part and maybe i am thinking this can be improved.
The dataset has chunk of groups. My final goal is to have the results for each group.
Currently the setup is as below.
- In main matlab script find group of chunk in dataset and call another matlab function.
- In 2nd matlab function, create arrays to hold output data for all datas in the group dataset, iterate through this group of data.
- Create the timeseries inputs for the feed in the simulink model.(only for the 1 data in dataset)
- The timeseries inputs are calculated based on the current 1 data and the previous output of the simulink model.
- Set the timeseries in SimIn and then call the sim command with rapid accelerator.
- Get the output results and assign it in the arrays created in point 2.
- Once the iterations are complete return to point 1 and save the output results in .mat file for analyzing later.
I think the point 5 & 6 are more time consuming and should be optimizied. So, i want to move the step 4 in the simulink model only as an m-function(closed loop). As a result, the point 3 would now have timeseries for all the datas in the group dataset and there would be only one call to the sim command and get all the result back.
But this work might be time consuming because step 3 is complicated and maynot be able to easily replicate in the simulink model. So, before restructring want to know whether there would be any performance improvement ?
I cannot optimize point 7 for storing data into .mat because many times due to working on other stuff matlab crashes and then loose all the results. Also, want to see output of in real time to stop if something very wrong happening on the simulation.