SUBPLOT : UPPER & LOWER PLOT

3 次查看(过去 30 天)
wan norhidayah
wan norhidayah 2020-12-12
回答: VBBV 2020-12-12
Hi,
how can i make a loop/simplfy for this coding?
x = linspace(0,10,100);
y = cos(3*x);
%Plot 1
subplot(6,2,1), plot(x,y)
title('y = cos(1x)');
grid on
xlabel('x')
ylabel('y')
%Plot 2
subplot(6,2,2), plot(x,y)
title('y = cos(2x)');
grid on
xlabel('x')
ylabel('y')
%Plot 3
subplot(6,2,3), plot(x,y)
title('y = cos(3x)');
grid on
xlabel('x')
ylabel('y')
%Plot 4
subplot(6,2,4), plot(x,y)
title('y = cos(4x)');
grid on
xlabel('x')
ylabel('y')
%Plot 5
subplot(6,2,5), plot(x,y)
title('y = cos(5x)');
grid on
xlabel('x')
ylabel('y')
%Plot 6
subplot(6,2,6), plot(x,y)
title('y = cos(6x)');
grid on
xlabel('x')
ylabel('y')

采纳的回答

VBBV
VBBV 2020-12-12
%true
for i = 1: 6
subplot(6,2,i)
y = cos(i*x);
plot(x,y)
title(sprintf('y = cos(%dx)', i));
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by