MATLAB: How to add a title to each subplot

nexttilesubplot titlestiledlayout

I have the following codes
delta=[-2*pi:0.063:2*pi];
y=sin(delta);
subplot(3,2,1)
plot(y)
y=cos(delta);
subplot(3,2,2)
plot(y)
title(sin(delta))
My question is how do i put the title for each graph and labels? i tried to to do title(sin(delta)) but it doesn't show

Best Answer

Starting in R2019b, you can use the tiledlayout and nexttile functions to create a configurable tiling of plots. The configuration options include:
  • Control over the spacing between the plots and around the edges of the layout
  • An option for a shared title at the top of the layout
  • Options for shared x- and y-axis labels
  • An option to control whether the tiling has a fixed size or variable size that can reflow
For more information, see Combine Multiple Plots.
For R2019a and before, put the title commands after the plot and before the next subplot. Specify the title as a character vector or string scalar.
delta=[-2*pi:0.063:2*pi];
y=sin(delta);
subplot(3,2,1)
plot(y)
title('sin(delta)')
y=cos(delta);
subplot(3,2,2)
plot(y)
title('cos(delta)')