フィルターのクリア

Subtract function from array

5 ビュー (過去 30 日間)
Jaap
Jaap 2011 年 12 月 13 日
Hi, I have a list of x/y coordinates. Is there an easy way to subtract a function (y = f(x)) from all y data? Thanks a lot!
Jacob

採用された回答

Jan
Jan 2011 年 12 月 13 日
Isn't this trivial?
f = @cos;
x = linspace(0, 2*pi, 100);
y = sin(x);
y2 = y - f(x);
or any other function instead of cos as long as it replies a vector with the same dimensions as the input.

その他の回答 (2 件)

Jaap
Jaap 2011 年 12 月 13 日
I was curious whether there was something quick like find(y-(@(x))). Thanks anyway.

Walter Roberson
Walter Roberson 2012 年 1 月 16 日
arrayfun(@(x, y) y - f(x), x, y)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by