Plotting functions using subplot
3 次查看(过去 30 天)
显示 更早的评论
Hi I hope you can help.
How do I plot funtions like this (see below) While using subplot?
f(x) = 3 sin2 (x) + cos(x/2), x ∈ [−3, 6.5]
g(x, y) = x 4 − 8y 2 + x + 4, x, y ∈ [−5, 5]
r(φ) = 2 + cos(5φ), φ ∈ [0, 2π]
Thank you!
回答(1 个)
Image Analyst
2023-9-9
% f(x) = 3 sin2 (x) + cos(x/2), x ∈ [−3, 6.5]
% g(x, y) = x 4 − 8y 2 + x + 4, x, y ∈ [−5, 5]
% r(φ) = 2 + cos(5φ), φ ∈ [0, 2π]
subplot(3, 1, 1);
x = linspace(-3, 6.5, 1000);
f = 3 * sin(x) .^ 2 + cos(x/2);
plot(x, f, 'r-', 'LineWidth', 2);
grid on;
xlabel('x')
ylabel('y')
subplot(3, 1, 3);
phi = linspace(-5, 5, 1000);
r = 2 + cos(5 * phi);
plot(phi, r, 'r-', 'LineWidth', 2);
grid on;
xlabel('phi')
ylabel('r')
To learn other fundamental concepts, invest 2 hours of your time here:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!