フィルターのクリア

Create An Array That Contains All the Values of F(x)? Help!

1 回表示 (過去 30 日間)
Steven
Steven 2013 年 9 月 19 日
I have a function f(x) that equals x if x < 1 and x^2 elsewhere.
How would I go about putting all the values of f(x) into another array, named y, for example?
  1 件のコメント
Steven
Steven 2013 年 9 月 19 日
If this helps x = linspace(-1,2,100).

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

採用された回答

Jan
Jan 2013 年 9 月 19 日
And to be complete:
y = x.^2;
y(x < 1) = x(x < 1);

その他の回答 (2 件)

James Tursa
James Tursa 2013 年 9 月 19 日
y = x;
y(y<1) = 1;
y = y.*x;

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 9 月 19 日
x=-5:5
y=(x<1).*x+(x>=1).*x.^2

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by