Modify or adding data in SimulationOutput

5 views (last 30 days)
Felix
Felix on 8 Dec 2023
Moved: Fangjun Jiang on 11 Dec 2023
Hello,
my request is related to the Simulink results that are written in Simulink.SimulationOutput. Is there a possibility to modify it, add something etc. via Matlab code?
Background:
I've designed a WebApp in which I've integrated a Simulink model. I've used a template that is described here: Generate and Deploy a MATLAB App with SimAppTemplate for a Model - MATLAB & Simulink - MathWorks Deutschland
I've also integrated an FMU model (although this information is probably rather unimportant at this point). The overall model and app/webapp runs fine. The results of the simulation are written to app.SimulationHelper.InputOutput.SimulationOutput and processed further by the app. Everything works fine.
Challenge:
Is there a way to cache a previous simulation call (that works) and then write it back to the "SimulationOutput" workspace? Apparently this is write-protected and this is not possible without further ado.
The background is that I want to display (plot) several different simulation runs and compare them (e.g. if I have changed a parameter).
My first idea (but it doesn't work yet):
Caching the results of the first simulation run. Perform the second simulation run. Load the previous results into SimulationOutput (however, this is read-only...).
I would be grateful for your ideas.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 9 Dec 2023
"Caching the results of the first simulation run. Perform the second simulation run."
If you can do both of the above, then you have the access to both simulation results. You don't need to read one to "over-write" another. Just read both results and plot them together.
  1 Comment
Felix
Felix on 11 Dec 2023
Moved: Fangjun Jiang on 11 Dec 2023
Hello Fangjun,
thanks for your reply.
I think I expressed myself somewhat imprecisely. I don't want to overwrite the results from SimulationOutput, I want to add data.
To be precise, when a new simulation is run through Simulink, the new simulation results replace (overwrite) the previous results in SimulationOutput. However, I would like to keep the old results. Therefore, I have saved them and would like to load them back into SimulationOutput after the new simulation run. Practically as a second result vector alongside the new ones that are generated. Because I do not have write permissions, this has not worked so far.
So I would like to know: Is it intentional that there are no write permissions in SimulationOutput (in principle certainly yes for now and there are certainly reasons for this)? But is there a way to change this? Or is there a way to load multiple result data into SimulationOutput?
Another background I forgot to write:
I would like to use the existing plotting routine that is used in the example and is based on Simulink.plotSelectedLoggedSignals. I find this very convenient. In the Matlab example for the app, this is implemented as follows:
app.SimulationHelper.UserInterface.plotSelectedLoggedSignals(app.SelectLoggedSignalsToPlotListBox, app.LoggedSignalsAxes);
This call requires that the results to be plotted are in Simulink.SimulationOutput (as far as I can see). So that's the real reason why I really want to have the data/results of several simulation runs in SimulationOutput.
If all else fails, I could of course write my own plotting routine.

Sign in to comment.

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!