how to plot this function?

3 visualizaciones (últimos 30 días)
Niloufar
Niloufar el 5 de Oct. de 2022
Comentada: Niloufar el 6 de Oct. de 2022

Respuesta aceptada

Image Analyst
Image Analyst el 5 de Oct. de 2022
Editada: Image Analyst el 5 de Oct. de 2022
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;

Más respuestas (1)

Torsten
Torsten el 5 de Oct. de 2022
f = @(x) abs(x)<=pi/2;
x = linspace(-pi,pi,200);
plot(x,f(x))
  1 comentario
Niloufar
Niloufar el 6 de Oct. de 2022
it worked thank you so much

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by