how to define the following function

How to define the following function in MATLAB
f(x) = 1 for 0<= x <= pi
f(x) = 1 for 0<= x <= pi

1 件のコメント

Walter Roberson
Walter Roberson 2013 年 1 月 21 日
You seem to have the same entry twice ?

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

回答 (1 件)

Thorsten
Thorsten 2013 年 1 月 21 日

0 投票

if 0 <= x && x <= pi, y = 0; end

1 件のコメント

Walter Roberson
Walter Roberson 2013 年 1 月 21 日
Or, vectorized:
y = zeros(size(x));
y(x >= 0 & x <= pi) = 1;

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

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

質問済み:

2013 年 1 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by