I have an external function that I require to call at most twice during the simulation. It has a large output of size Real[n][m][k] where n, m, and ks product is a relatively large integer. I call the function inside a when statement. The issue I have is that the output of the function is copied over and over in .mat file for each iteration and causes it to be really large even though I use the output infrequently. I wonder if there is a way to store the output only once and avoid storing the copies of the output in the results file for each time step.
P.s. If that is not possible I might try to store the results of the function in another file, but need to use them in the simulation. So as an alternative is there also a way to make the simulation ignore storing a variable in the results file.