I am using Matlab 2019b and the app builder to run a function when a button in the application is clicked. The funcation outputs the data to make it accesible within the app builder 'code view'. That data is then passed into a different function contained with the application. This function plots the data and creates a legend.
I would like to be able to have the user run the app, see the figure, then change parameters in the app and run it again and see the new data apprear on the same figure. When the app is run for the second time the line shows on the plot in a different color as expected, however the legend overwrites the previous legend and doesn't perserve the entry from the first 'run'. How to I perserve the legend and keep adding data to the figure while perserving the legend?
Note: I have tried using hold on, hold all, ... doesn't seem to work.
After running app once:
After updating some inputs and running app again: