Matlab用subplot画图,怎么加总标题

2025-04-08 07:17:50
推荐回答(1个)
回答1:

你用suptitle命令即可。下面是该命令的帮助文档。
suptitle('text') adds text to the top of the figure

above all subplots (a "super title"). use this function

after all subplot commands.下面是一个例子,注意,最好画完所有的子图后再用suptitle,不然可能会出现和第一个子图的标题覆盖的情况。
clc;clear;close all
x = 0:0.01:4*pi;
y1 = cos(x);
y2 = sin(x);
figure(1)
subplot(2,1,1);
plot(x,y1);
title('cos(x)');
subplot(2,1,2);
plot(x,y2);
title('sin(x)');
suptitle('总标题')下面是结果: