Reputation: 379
In my program, I am doing a least squared optimization problem, i.e. \sum_{i} (y_{i}-y_{i}^{market})^2
. At the same time, I want to plot the modeled y_{i}
against the y_{i}^{market}
. To program it which suit my needs, I define OutputFcn
during my optimization and write the code as follow: (Suppose x
represent the x-coord
figure()
hold on
plot(x,[y_{1},y_{2},...,y_{n}]);
plot(x,[y_{1}^{market},y_{2}^{market},...,y_{n}^{market}]);
When I run the program, I can draw a new calculated curves on the same plot. Unfortunately, the final plot is difficult to view it. In order to make it to be visible to read, I want to delete the curve (calculated values) obtained in the previous iteration and plot the new curve (calculated values) in the new iteration on the existing plot. What should I do to the current code to fulfill my needs?
Upvotes: 0
Views: 59
Reputation: 35525
Something like:
hold on
for iterations
clf
% PLOT STUFF
drawnow
pause(0.1)
end
clf
clears the figuredrawnow
forces drawing on screenpause
stops execution for a bit so you have time to see it.Upvotes: 2