how to plot this function?

조회 수: 2 (최근 30일)
Niloufar
Niloufar 2022년 10월 5일
댓글: Niloufar 2022년 10월 6일

채택된 답변

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
Niloufar
Niloufar 2022년 10월 6일
thank you for your help

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Torsten
Torsten 2022년 10월 5일
f = @(x) abs(x)<=pi/2;
x = linspace(-pi,pi,200);
plot(x,f(x))
  댓글 수: 1
Niloufar
Niloufar 2022년 10월 6일
it worked thank you so much

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by