how to plot this function?

2 次查看(过去 30 天)

采纳的回答

Image Analyst
Image Analyst 2022-10-5
编辑:Image Analyst 2022-10-5
Here is one way:
x = linspace(-pi, pi, 1000);
f = zeros(1, length(x));
f(abs(x) <= pi/2) = 1;
plot(x, f, 'b-', 'LineWidth', 2)
ylabel('f');
xlabel('x');
grid on;

更多回答(1 个)

Torsten
Torsten 2022-10-5
f = @(x) abs(x)<=pi/2;
x = linspace(-pi,pi,200);
plot(x,f(x))

类别

Help CenterFile Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by