overwrite figure(2) on figure(1)

6 views (last 30 days)
elena
elena on 2 Dec 2022
Answered: Star Strider on 2 Dec 2022
MatLab open all the figure except for the number 2 and I can't understand why. In fact if I use:
figure
fplot(f,[-pi,pi])
figure
fplot(g)
it plot the first one in figure(1) and the second one in figure(3). If I would use this code it will overwrite on figure(1).
figure(1)
fplot(f,[-pi,pi])
%
figure(2)
fplot(g)

Answers (1)

Star Strider
Star Strider on 2 Dec 2022
I am not certain what you are asking. Consider using the hold function to plot two figures on the same axes —
syms x
f = sin(x);
g = cos(x);
figure
fplot(f, [-pi pi], 'DisplayName','sin(x)')
hold on
fplot(g, [-pi pi], 'DisplayName','cos(x)')
hold off
grid
legend('Location','best')
.

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!