Commands for Interactive Work (in the console)

$\texttt{clc/clc()}$ - clears the console

$\texttt{clear/clear all/clear a/clear('a')}$ - removes all variables/same/removes variable a/same

$\texttt{who/who()}$ - print existing variables

In [1]:
a = 2;
b = 2;
who()
clear a;
who()
Variables in the current scope:

a    ans  b

Variables in the current scope:

ans  b

$\texttt{close/close 1/close(1)/close all}$ - closes current figure/closes figure 1/same/closes all figures

In [2]:
figure(1);
plot(1:10, sin(1:10));
close(1); % I close the figure before it can be shown

Files and Directories

$\texttt{pwd/pwd()}$ - prints the current working directory

$\texttt{ls/ls()}$ - lists all files in the current working directory

$\texttt{rm('filename')}$ - deletes a file (immediately and permanently)

Figures

$\texttt{gcf/gcf()}$ - get current axis

$\texttt{gca/gca()}$ - get current axis

$\texttt{clf/clf()}$ - clear current figure

$\texttt{sprintf}$ - like $\texttt{fprintf}$ but prints to a string

In [3]:
figure();
hold on;
x = linspace(0, 10, 1000);
for trial = 1:5
    label = sprintf('Trial %d', trial);
    plot(x, sin(x + 2 * pi * rand()), 'DisplayName', label);
end
legend('show');
Gnuplot Produced by GNUPLOT 5.2 patchlevel 6 -1 -0.5 0 0.5 1 0 2 4 6 8 10 Trial 1 Trial 1 Trial 2 Trial 2 Trial 3 Trial 3 Trial 4 Trial 4 Trial 5 Trial 5