how to plot this function?

2 Ansichten (letzte 30 Tage)
Niloufar
Niloufar am 5 Okt. 2022
Kommentiert: Niloufar am 6 Okt. 2022

Akzeptierte Antwort

Image Analyst
Image Analyst am 5 Okt. 2022
Bearbeitet: Image Analyst am 5 Okt. 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;

Weitere Antworten (1)

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

Kategorien

Mehr zu Simulation, Tuning, and Visualization finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by