MATLAB Answers

Duplicate live script figure appearing

21 views (last 30 days)
Charles Refvem
Charles Refvem on 13 Apr 2021
Answered: Arthi Sathyamurthi on 27 May 2021
I have a live script that produces many plots, each on their own figure. For some reason a plot from the top portion of my live script is duplicated at the bottom of my script as well. It is really confusing me because I am directly calling out the figure number before every set of plot commands, so there should be no chance of plots appearing on the wrong figure.
The weirdest part is that if I put a breakpoint in where the phantom plot appears, run the live script to the breakpoint and then simply press continue, the phantom plot does not appear. So, the same exact code simply executed with a breakpoint does not cause the same issue to occur.
Are there certain plot features or functions that don't work properly in live script? Is there a recommended workflow for using figures in a live script? Am I not supposed to use the figure command at all?
I'm working with R2020b, but I have observed this problem several times in previous versions of MATLAB as well.
I can post the script if requested, but it has several associated simulink models and is quite lengthy.

Answers (1)

Arthi Sathyamurthi
Arthi Sathyamurthi on 27 May 2021
There are few possible reasons this might have happened in your case,
  1. Sometimes you might have initialized or created an object for the figure at the position where the phantom plot appears and. I assume due to certain initial conditions of your program during the first loop till your breakpoint, the phantom plot doesn’t appear when you run till the breakpoint. Check if you have initialized the figure and visualized it before updating the figure.
  2. In case you are using a loop, with the figure functions, run the loop with the breakpoint continuously and check if you are getting the phantom plot at some point which will help you rectify the problem.
In case, if the workarounds are not solving your problem, kindly post the script where you are facing this issue, which would be easier to reproduce the issue on our side and let you know the solution

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!