A brief description (in case I'm turning this into a xy problem):
I'm working on a project where we are conducting run to failure experiments for a UAV and have two identical simulink models, except one of them has some extra monitoring and log output. We run the UAV mission, then degrade some of the parameters, and repeat this over and over until the UAV crashes or violates a safety threshold. This is good, but we want to know before the UAV actually crashes, which is where the parallel part comes in. We simulate the "digital twin" in parallel to collect many samples after each real mission, and then generate a distribution from those samples that can tell us if the UAV is going to crash on the next mission. With a 1D polyfit and sliding window, we can forecast a few missions out. In order for this to work, the degradation parameters from the main workspace with the real UAV need passed to each parallel workspace. The problem is that I am getting an error "Array indices must be positive integers or logical values" for each of the parallel workers.
I have a function called parallel_initializer_handler() that is executed on line 173 of next_paper.mlx which creates the workspace for each parallel worker. When I execute this function in the main workspace, I do not get any error, and the struct which I am updating is successfully updated.
This is how I am setting this up:
in(n) = Simulink.SimulationInput("digitaltwin1c");
out = parsim(in, 'ShowSimulationManager',"off", 'ShowProgress',"off", "UseFastRestart", "on", "SetupFcn", @()parallel_initializer_handler(i, lookback, horizon, r_var, q_var, m_var, twin_sample_rate));
Should I approach this differently? How can I peer into each of the parallel workspaces to see what is happening? How can I fix the error, and know that I am passing variables correctly? How can I get some output that says, "this is parallel worker X, the value of my variable is Y" ?