Команда
в MATLAB. Вот несколько способов создания подграфиков с примерами кода:
Метод 1: использование функции subplot
% Example data
x = linspace(0, 2*pi, 100);
y1 = sin(x);
y2 = cos(x);
% Create a figure and divide it into subplots
figure;
subplot(2, 1, 1); % 2 rows, 1 column, first subplot
plot(x, y1);
title('Subplot 1');
xlabel('x');
ylabel('y1');
subplot(2, 1, 2); % 2 rows, 1 column, second subplot
plot(x, y2);
title('Subplot 2');
xlabel('x');
ylabel('y2');
Метод 2: использование команды clf
% Example data
x = linspace(0, 2*pi, 100);
y1 = sin(x);
y2 = cos(x);
% Create a figure
figure;
% Plot the first subplot
subplot(2, 1, 1); % 2 rows, 1 column, first subplot
plot(x, y1);
title('Subplot 1');
xlabel('x');
ylabel('y1');
% Clear the current figure without closing it
clf;
% Plot the second subplot
subplot(2, 1, 2); % 2 rows, 1 column, second subplot
plot(x, y2);
title('Subplot 2');
xlabel('x');
ylabel('y2');
Эти методы демонстрируют, как создавать вложенные графики с помощью функции subplotи команды clfв MATLAB. Первый метод создает подграфики напрямую с помощью функции subplot, а второй метод очищает текущий рисунок с помощью clf, а затем последовательно строит подграфики.