Plotting

Set axis titles

title('thetitle')
xlabel('xaxis')
ylabel('ytitle')

Set axis scales

set(gca, 'YScale', 'log')
set(gca, 'XScale', 'linear')

Set axis aspect ratios

set(gca, 'DataAspectRatio', [1 1 1])

Enable grid

grid('on')
grid('minor')

Enable legends

legend
legend('location', 'Southeast')

Just plot

plot(x, y, '-gx', 'DisplayName', 'Titleforlegend')
loglog(x, y, '-gx', 'DisplayName', 'Titleforlegend')

Make nice for generating plots

set(gcf, 'color', 'w')
set(gcf, 'Position', [100, 50, 800, 600])
set(gcf, 'DefaultLineLineWidth', 2)

Subplots

subplot(3,3,1)
sublpot(3,3,2)

Tiling

figure(1)
tiledlayout(2,1)

Move to next tile

nexttile

Span over multiple tiles

tlt = nexttile([1 2])

Remove padding/spacings

tlt.Padding = "none";
tlt.TileSpacing = "none";

Timing

Place tic at the start of the program, and toc at the very end to time roughly how long it takes to run

tic
[something]
toc

Random

Gaussian random

rng('default')
randn(n,m)

Normal Random

normrnd()