在 MATLAB 中,可以使用以下简短的命令计算并绘制在 0 < x < 6 范围内的 sin(2x)、(sin(x))^2 和 sin(x^2):

x = 0:0.1:6; % 定义x的范围和步长
y1 = sin(2*x); % 计算sin(2x)
y2 = (sin(x)).^2; % 计算(sin(x))^2
y3 = sin(x.^2); % 计算sin(x^2)

subplot(3,1,1); % 创建一个3行1列的子图,并选择第1个子图
plot(x, y1); % 绘制sin(2x)
title('sin(2x)'); % 添加标题

subplot(3,1,2); % 选择第2个子图
plot(x, y2); % 绘制(sin(x))^2
title('(sin(x))^2'); % 添加标题

subplot(3,1,3); % 选择第3个子图
plot(x, y3); % 绘制sin(x^2)
title('sin(x^2)'); % 添加标题

sgtitle('函数图像'); % 添加总标题

执行上述代码后,将会得到一个包含三个子图的图像,分别表示 sin(2x)、(sin(x))^2 和 sin(x^2) 在 0 < x < 6 范围内的图像。


原文地址: https://www.cveoy.top/t/topic/phua 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录