how to plot this function?

 采纳的回答

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 个)

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

类别

帮助中心File 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