clear plots in matlab

To clear plots in Matlab, you can use the clf (clear figure) command. This command will clear the current figure window and its contents.

To clear all figures at once, you can use the close all command. This will close all figure windows, including any that are hidden or minimized.

Here's an example of how to use clf:

main.m
% plot some data
x = 1:10;
y = rand(1,10);
plot(x,y);

% clear the plot
clf;
77 chars
8 lines

And here's an example of how to use close all:

main.m
% plot some data
x = 1:10;
y = rand(1,10);
figure;
plot(x,y);

% create another figure and plot some data
figure;
z = rand(1,10);
plot(x,z);

% close all figures
close all;
173 chars
14 lines

related categories

gistlibby LogSnag