overwrite figure(2) on figure(1)

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)

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 Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2022b

Tags

Asked:

on 2 Dec 2022

Answered:

on 2 Dec 2022

Community Treasure Hunt

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

Start Hunting!