採用された回答

Image Analyst
Image Analyst 2022 年 10 月 5 日
編集済み: Image Analyst 2022 年 10 月 5 日

0 投票

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 日

0 投票

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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

タグ

質問済み:

2022 年 10 月 5 日

コメント済み:

2022 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by